Android launchMode singleTask

If we have 2 actions, A and B , both of which are defined as singleTask in AndroidManifest.xml , when A starts B , A will be closed ( onDestroy() is called immediately). Why is this happening and how to avoid A to shut down the system (multiple singleTask actions in one application)?

+4
source share
5 answers

From the documentation:

"singleTask" and "singleInstance" activities can only begin a task. They are always at the root of the activity stack.

Since the system cannot have two root actions, all previous actions are closed when such a task starts.

+5
source

Can you provide sample code and a manifest demonstrating this problem? To reproduce it, I created a simple application with two applications in which both actions have launchMode = "singleTask" and where Activit1 starts Activity2. This works as expected (Activity1 is not immediately destroyed). I assume that you are doing something else either in your code or in your manifest, which causes the behavior that you are describing. Please send the code and manifest so that we can help with your problem.

+1
source

Perhaps this is due to the affiliation of the task .

0
source

I had the same problem. I set the startup mode for activity B as "singleInstance", it solved the problem.

0
source

From what I tested onDestroy does not start on Android 5.1

0
source

Source: https://habr.com/ru/post/1337590/


All Articles