Condition: I have a client activity "X" of a remote service (with AIDL) that calls the bindService() in the onCreate() and unbindService() in the onDestroy(). Assume that this activity has been started but not in the foreground (onStop() has happened).

It is said that when android system needs more memory elsewhere it might kill the process of another activity with less priority (possibly "X").

If, says, the android system decides to kill "X"'s process, according to the activity-lifecycle diagram the onDestroy() will not be called if the process is killed when more memory is needed. http://developer.android.com/guide/topics/fundamentals/activities.html

Question: Will this cause it to leak the service connection? Is it safer then to bind and unbind service in onStart() and onStop()?

Thanks in advance!

有帮助吗?

解决方案

Question: Will this cause it to leak the service connection?

The ServiceConnection object would be in the process of "X" and therefore will go away when that process is terminated.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top