I'm using a LocalActivityManager to have activities in different tabs, when I switch from a tab to another one, I start the Activity corresponding to the tab selected.
My problem is simple :
if I click on tab 1, I create intent11 and the first time, the method onCreate(Bundle emptyBundle) of Activity1 is called.
If I click on tab 2, I create intent2 and the method onCreate() is called.
Then, when I click on tab1, I create intent12 , the method onCreate(Bundle emptyBundle) is not called but onResume() is called (normal behavior).
I put special extras in the intent11 and intent12 to create Activity1, so I access it using getIntent().getExtras().
My problem is : the second time I go to the tab1, the intent12 is used to start the Activity, but the result of getIntent() is still intent11.
So I can't retreive the extras set in intent12, I can only retreive the extras set in intent11.
What am I doing wrong ? Should I avoid putting extras() in the intents ? Thank you.
Thank you.
PS : for the moment, I set a special flag to my intent to force to call onCreate(), but I'm sure it's not the good way of doing it.
I believe what you are looking for is here: https://developer.android.com/reference/android/app/Activity.html#onNewIntent%28android.content.Intent%29
onNewIntent(Intent newIntent) allows you to override the previous intent that was used to create/resume the app with the newest intent.
In Xamarin.Android / Monotouch I just added the following method to my Activity and it worked smoothly.
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
Intent = intent;
}
The principle should work fine also in Native Android.
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