Question

I am relaunching my HomeActivity and setting an extra "relaunchstatus" in the Intent. In Activity's onCreate() method I check this value, if present, show some alert.

The launchmode for this activity is android:launchmode="singleTask".

The issue comes after the user sees this alert and close it and again close the activity by pressing Back button. Now if he starts it from Recent list of apps by long pressing 'Home' button, then the same intent which had an extra "relaunchstatus" in it is used and again the alert comes.

This keeps on as long as user comes from the recent items (OK, may be recent launch apps uses the same intent which had the extra "relaunchstatus" set in it).

So I tried to remove this extra by handling BACK_KEY press just before the activity finishes itself, using getIntent().removeExtra("relaunchstatus") , still this extra exists in the new launch from Recent items.

However this is not the case if I start the app from launcher menu icon.

Update: So I guess Activity's getIntent() will give you a copy of Intent that launched it, so its not like a reference to same object on which changes will be permanent. If this is the case, then we will need to do it from current device GUI (like HTC Sense etc. ) , whose recent items are bind to that intent , which may not be possible ?

Was it helpful?

Solution 2

This cannot be changed, infact no Intent exists as per post by Dianne Hackborn here : Android Google Groups

OTHER TIPS

If launch mode is singleTask and Activity already exists than instead of onCreate(), the onNewIntent(..) will be invoked.

So you need to override onNewIntent(..) and check the Intent there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top