关于onServiceDisconnected不会被调用的问题

在获得一个ServiceConnection实例时需要覆写onServiceConnectedonServiceDisconnected两个方法,一直疑惑onServiceDisConnected方法为什么在主动unbindService后不会调用,查了官方文档后有初步的了解

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 Developer

大概的意思是onServiceDisconnected只会在Service丢失时才会调用, 通常会在Service所在进程被迫终止时才会调用, 当Service重新运行时会再次调用onServiceConnected方法

发布了9 篇原创文章 · 获赞 1 · 访问量 7813
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览