How can I make sure I only retain one copy of an activity on the stack when called from non-activity?
When called from an activity I can just add the FLAG_ACTIVITY_REORDER_TO_FRONT flag to the Intent, but how can I do this from e.g. a widget or a notification?
From stackoverflow
-
When launching an
Activity
from a notification, you're required to create a new task by setting theFLAG_ACTIVITY_NEW_TASK
flag.Since you're required to do this, you can restrict that
Activity
to only having one instance by addingandroid:launchMode="singleTask"
to its manifest entry.greve : That won't work the way I intend it to because if you select activity A, B, C and then A again, both B and C will be removed from the stack. Given that activity A has `android:launchMode="singleTask"` in the manifest.Christopher : Ah, true. I had the same problem with an app I worked on; I forgot that launching from a notification does indeed an existing history stack. And FLAG_ACTIVITY_REORDER_TO_FRONT doesn't help in this case (and furthermore is buggy on some devices). Bah.
0 comments:
Post a Comment