This may be discussed before, but i didn't find answer. I've problem with my application beeing killed when some other apps needs memory. I looked at Activity Lifecycle and tested my app. All i want to know is: when in one of my processes are called onPause() or onStop() and other apps needs memory, how to avoid from my process being killed.
You can't avoid this. When system needs memory or does cleanup, it can kill application.
However you may somehow control importance of your application, so that it may live longer. Read here about importance of various application parts related to process killing: http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html#Lifecycle
To have long-running application, implement Service. However, also Service may be killed, but system schedules to restart killed or crashed services after some time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With