Sviatoslav
Sviatoslav

Reputation: 1312

Send data to the old activity

I am starting my old Activity by using Flags Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP but I cann't send String to this Activity by using putExtra:

Intent intent = new Intent(INTENT_ActivityA);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("DATA", "OK");
startActivity(intent);

in the onResume getIntent().getStringExtra("DATA")==null

How to send data to the running Activity?

Upvotes: 2

Views: 1558

Answers (1)

Vny
Vny

Reputation: 196

If you override onNewIntent i think you should be having your data in it. Try following

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    intent.getStringExtra("DATA");
} 

Hope it helps!

Upvotes: 9

Related Questions