Reputation: 3865
My app has both Service and Activities.
Suppose the process of my app is running. And after a while, the Android OS kills the service in my app due to low memory. My question is, is it possible that Android kills the service only and keeps the process alive? Or when a service is killed, the process must be killed too?
Thanks.
Upvotes: 3
Views: 861
Reputation: 5945
I'm 99,9% sure of this: if the service goes, there goes the process too. The conditions to kill a service are pretty demanding such as in low memory situations. My own experience is that the whole app is killed when the service dies. The service and the process are tied together. Yes, you can manually stop your service without killing your process, but I'm almost certain that when the OS kills your service because of low memory, then bye-bye process.
See Hackbod's answer and comments: Android service killed
See http://developer.android.com/reference/android/app/Service.html and onLowMemory:
This is called when the overall system is running low on memory, and would like actively running process to try to tighten their belt. While the exact point at which this will be called is not defined, generally it will happen around the time all background process have been killed, that is before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.
Background info: http://about-android.blogspot.com/2010/07/lifecycle-of-android-application.html
This is also interesting: Will we leak the android service connection if the client's process is killed by android?
Upvotes: 3