Reputation: 31604
In an app I have very reused Activity, that shows a list of stuff happening on a specific day. The day is specified using Intent Extras.
My problem is, that if the user starts at day=1
, then chooses day=2
and then day=1
, from the menu, then I would like the back button to go to day=2
and then home. That is, I want to do REORDER_TO_FRONT
, but not just based on the name of the activity, but also its extras.
There doesn't seam to be any intent flags suitable for this purpose. I've considered implementing my own 'sub activity stack' using onNewIntent
, but it probably wouldn't work very well.
Have you tackled similar problems in your apps? Is there perhaps a way to programmatically access the activity stack, and choose which one is suitable to return to?
Upvotes: 0
Views: 516
Reputation: 2578
Manage your own Activity stack! If I'm not mistaken, you use the same Activity to display each day. Make it single top (FLAG_ACTIVITY_SINGLE_TOP). In the launching intent, pass on the current stack, in your example "121".
Respond to the back button event by launching your Activity with a smaller stack: "12" - or if stack is already "", then just let the Activity handle Back event. Then as you mentioned, use the onNewIntent function to update your Activity.
Upvotes: 1