我们将泄漏了Android服务连接如果客户端的过程是由机器人被杀? [英] Will we leak the android service connection if the client's process is killed by android?
问题描述
条件:
我有一个客户端活动调用一个远程服务(以AIDL)的X的 bindService()
在的onCreate()
和 unbindService()
在的onDestroy()
。假设该活动已经启动,但没有在前台(的onStop()
已经发生)。
有人说,当Android系统的其他地方需要更多的内存,它可能会用更少的优先级(可能是X)杀了另一个活动的过程。
如果说,Android系统决定杀X的过程中,根据活动生命周期图中的的onDestroy()
将不会被调用,如果需要更多的内存时,进程被杀死。
http://developer.android.com/guide/topics/fundamentals/activities.html
问:
这是否会导致其泄漏服务连接?它是安全的,然后绑定,并在在onStart解除绑定服务()
和的onStop()
在此先感谢!
问:请问这导致其泄漏服务连接
块引用>的
ServiceConnection
对象将是在X的过程,因此当进程终止会自行消失。Condition: I have a client activity "X" of a remote service (with AIDL) that calls the
bindService()
in theonCreate()
andunbindService()
in theonDestroy()
. 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.htmlQuestion: Will this cause it to leak the service connection? Is it safer then to bind and unbind service in
onStart()
andonStop()
?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.这篇关于我们将泄漏了Android服务连接如果客户端的过程是由机器人被杀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!