After Android crosses the task of the child process from the recent task list, the main process task is also closed, how can i keep alive?
Asked
Active
Viewed 111 times
-1
-
Does this answer your question? [Prevent activity from being destroyed as long as possible](https://stackoverflow.com/questions/22168287/prevent-activity-from-being-destroyed-as-long-as-possible) – philoopher97 Jul 08 '21 at 10:30
-
No, there are two activities, which one was launched bg Intent.FLAG_ACTIVITY_NEW_DOCUMENT and Intent.FLAG_ACTIVITY_MULTIPLE_TASK.When we open recentList and close the second, the main activity was destroy too. This will happen in some of Android phone. – Aaron Jul 08 '21 at 13:00
-
how about adding 1 more flag `android.content.Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS`, did it works retaining your main activity? This is suggested in https://developer.android.com/guide/components/activities/recents#retain-finished – mochadwi Jul 09 '21 at 15:34
1 Answers
0
Use a service instead...
A service is a general-purpose entry point for keeping an app running in the background for all kinds of reasons. It is a component that runs in the background to perform long-running operations or to perform work for remote processes.
Learn more about Basics of Android

philoopher97
- 772
- 1
- 6
- 18
-
Thanks, but it is not the solution of my question. Suppose there are two activities, which one was launched bg Intent.FLAG_ACTIVITY_NEW_DOCUMENT and Intent.FLAG_ACTIVITY_MULTIPLE_TASK.When we open recentList and close the second activity, the main activity was destroy too. This will happen in some of Android phone. – Aaron Jul 08 '21 at 13:06