我们将泄漏了Android服务连接如果客户端的过程是由机器人被杀? [英] Will we leak the android service connection if the client's process is killed by android?

查看:225
本文介绍了我们将泄漏了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 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.

这篇关于我们将泄漏了Android服务连接如果客户端的过程是由机器人被杀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆