If a service is deemed unimportant, it might be killed by the system. I am aware that onDestroy()
is not guaranteed to be called when the process is killed too but in situations where the calls go through (like if the service is killed while process is still kept alive), is onUnbind()
called along with onDestroy()
to release the binder, or is onUnbind()
specifically reserved to be called after unbindService()
, as such only onDestroy()
will be called?
I would also like to have a clarification on the exact conditions for onServiceDisconnected()
to be called and if it related to the same problem. My current guess is that it gets whenever the service is killed without an unbindService()
call. Am I right to think so?
I have tried testing it by using ADB commands like in this answer to simulate a low memory environment but even with the RUNNING_CRITICAL
setting, bound service was not being killed, so I could not test it.