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) is called, the control goes to onResume() of the CalledActivity.
However, in the onResume() of the CalledActivity, getIntent() gives me the old intent and not the new intent as set by the CallingActivity.
How can I get the new intent in onResume() of the CalledActivity??
You should try to override the onNewIntent (Intent intent)
method of Activity, and use setIntent(Intent)
to update the intent.
To expand on dreamtale's answer, just add the following method to your Activity.
@Override
public void onNewIntent (Intent intent) {
setIntent(intent);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With