gpt4 book ai didi

android - 调用 Service stopSelf() 后未调用 onServiceDisconnected()

转载 作者:IT老高 更新时间:2023-10-28 22:16:13 24 4
gpt4 key购买 nike

我有一个 Activity,我在其中启动并绑定(bind)到下载 Service

Service中调用stopSelf()时,Activity中的onServiceDisconnected()不会被调用。

我希望它会被调用,因为如果 Service 停止,所有绑定(bind)的 Activity 都应该解除绑定(bind)。

我错过了什么?

最佳答案

根据官方文档,onServiceDisconnected() 会在服务崩溃或被杀死时被调用。友情链接 http://developer.android.com/reference/android/content/ServiceConnection.html

Called when a connection to the Service has been lost. This typically happens when the process hosting the service has crashed or been killed. This does not remove the ServiceConnection itself -- this binding to the service will remain active, and you will receive a call to onServiceConnected(ComponentName, IBinder) when the Service is next running.

关于android - 调用 Service stopSelf() 后未调用 onServiceDisconnected(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17713453/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com