I have almost the same requirements as this excellent question:
Send data to activity with FLAG_ACTIVITY_REORDER_TO_FRONT
However, I'm using FLAG_ACTIVITY_NEW_TASK
because each of my primary activities needs to run as a new task. In my testing onNewIntent
isn't called in this case (even when activity already running). So how do I pass data to it?
I can get onNewIntent
to be called, by setting launchMode
to singleTask
, however then I run in to this bug: Android: bug in launchMode="singleTask"? -> activity stack not preserved
I want to accomplish:
If no instance exists, create a new instance, as a new task, and pass it data. (this part already works, I can get the data in onCreate)
If an instance already exists, bring the task (entire task, not just root/one activity) it is in to the front, and:
If task currently has a child activity displayed, do nothing
If task doesn't have a child activity displayed (just root/main activity), process the passed data and update the UI
I have one task with a button, "Go to Event", when clicked it needs to open/start the Calendar task and highlight a specific event (but the Calendar will ignore that request if another activity is being displayed over the top of it).