I have an existing activity with a MediaPlayer that still running after onStop() was called.
I want to reload this activity but passing it different extra values.
Intent intent = new Intent(WelcomeScreen.this, PlayMusic.class);
intent.putExtra("plan", 0);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
But, that extra is "stuck" with the same values no matter what I put on the new intent.
Any ideas?
As you clearly state, you create a new Intent object. Whatever were the paramters associated with the old Intent, the one that was used to initially create the Activity, they were not affected.
However, you can access the new Intent by overriding Activity's onNewIntent() method:
@Override
protected void onNewIntent(Intent intent)
{
super.onNewIntent(intent);
if ( intent != null && intent.hasExtra("plan") )
{
// Yay! Do whatever... Live long... Prosper...
}
}
You have to set new intent explicitly in onNewIntent callback
override fun onNewIntent(intent: Intent) {
super.onNewIntent(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