androidandroid-activityandroid-intentrelaunch

getIntent().removeExtra() in Activity doesn't work for android:launchmode="singleTask"?


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 ?


Solution

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