Getting old intents in onResume () after startActivity (newIntent)

In the calling activity, I have the following code:

Intent intent = new Intent();
intent.setClass(CallingActivity.this, CalledActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(key, new_value);
startActivity(intent);

      

After the startActivity (intent) function is called, the control goes to the onResume () of the called activity.

However, in onResume () CalledActivity getIntent () gives me the old intent, not the new intent given by CallingActivity.

How can I get new intent in onResume () of CalledActivity ??

+3


source to share


2 answers


You should try to override onNewIntent (Intent intent)

Activity method and use setIntent(Intent)

intent to update.



+9


source


To expand on DreamTale's answer, just add the following method to your activity.



@Override
public void onNewIntent (Intent intent) {
    setIntent(intent);
    super.onNewIntent(intent);
}

      

+1


source







All Articles