Android: how to avoid my process being killed

This can be discussed earlier, but I did not find the answer. I have a problem with my application that was killed when some other applications need memory. I looked at the Activity Lifecycle and tested my application. All I want to know is: when onPause () or onStop () is called in one of my processes, and other applications need memory, how to avoid this process.

+5
source share
2 answers

You cannot avoid this. When a system needs memory or performs a cleanup, it can kill the application.

However, you can somehow control the importance of your application so that it can live longer. Read here about the importance of the various parts of the app related to the killing process: http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html#Lifecycle

To have a long-term application, run the service. However, a service may also be killed, but system schedules for restarting killed or broken services after some time.

+6
source

This is not possible, every application is handled the same way on android, and one of the things you should consider is that your application may be killed. You can support running services that can do what you want if it is something in the background.

+1

All Articles