In my situation, there is one case in which I need to make sure the activity only runs one at a time.
I found if I set the LauchMode
of the activity, I
In your manifest, use android:launchMode="singleTask"
instead of android:launchMode="singleInstance"
. Using singleInstance only returns to the existing instance if it is at the top of the stack. singleTask, on the other hand, return to the existing instance of the activity, as it is always at the root of the task.
Then, when your instance is launched, override onNewIntent to update your UI according to the new intent.
Refer to the Andorid documentation for details.