I want to send data (String) from service to Activity. How can I do that? this is my service and I want to send the token to RegisterActivity, but it doesn't work
public class FirebaseInstanceIDService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh() {
String token = FirebaseInstanceId.getInstance().getToken();
Log.d("My firebase id", "Refreshed token: " + token);
Intent intent = new Intent(getApplicationContext(), RegisterActivity.class);
intent.putExtra("TokenValue", token);
FirebaseInstanceIDService.this.startActivity(intent );
}
In RegisterActivity
Intent intent = getIntent();
String tokenValue = intent.getStringExtra("TokenValue");
Toast.makeText(RegisterActivity.this,tokenValue,Toast.LENGTH_SHORT).show();