Reputation: 261
We would like to add a flag using Java while starting an Activity. But we cannot find the equivalent of setting launchmode="single task" equivalent flag. thx in advance
Upvotes: 0
Views: 629
Reputation: 753
I was able to solve this with the following combination;
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
Hope this helps!
Upvotes: 0
Reputation: 67229
It sounds like you are looking for a combination of FLAG_ACTIVITY_NEW_TASK
, FLAG_ACTIVITY_SINGLE_TOP
and FLAG_ACTIVITY_CLEAR_TOP
.
From the FLAG_ACTIVITY_CLEAR_TOP
documentation:
if FLAG_ACTIVITY_SINGLE_TOP is set then this Intent will be delivered to the current instance's onNewIntent().
...
This launch mode can also be used to good effect in conjunction with FLAG_ACTIVITY_NEW_TASK: if used to start the root activity of a task, it will bring any currently running instance of that task to the foreground, and then clear it to its root state. This is especially useful, for example, when launching an activity from the notification manager.
Upvotes: 1