Saturday, September 17, 2011

[android-developers] getIntent().removeExtra() in Activity doesn't work for android:launchmode=“singleTask”?

0 down vote favorite
share [fb] share [tw]


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.

Also, I finish my activity before relaunching, in this particular
case. Hence its onCreate() is called instead of onNewIntent() as it do
not exist in the task stack. In other cases I need it to reuse, so
cannot remove the "singleTask" option

So If Activity's getIntent() is giving you a copy of Intent that
launched it, its not like a reference to same Intent 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 ?

One way is to set setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS),
while restarting it again. So for this case it won't appear in recent
menu, still there needs to be some other way ?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate