Will we leak the android service connection if the client's process is killed by android?

别等时光非礼了梦想. 提交于 2020-01-04 01:57:07

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/7633317/will-we-leak-the-android-service-connection-if-the-clients-process-is-killed-by

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!