Android使用unbindService解绑服务时,未调用ServiceConnection的onServiceDisconnected回调方法

原文链接:https://blog.csdn.net/qq_27840621/article/details/69525064

1、onServiceDisconnected() 在连接正常关闭的情况下是不会被调用的.

2、该方法只在Service 被破坏了或者被杀死的时候调用. 例如, 系统资源不足, 要关闭一些Services, 刚好连接绑定的 Service 是被关闭者之一, 这个时候onServiceDisconnected() 就会被调用.

其它参考:https://www.runoob.com/w3cnote/android-tutorial-service-1.html

  • ServiceConnection对象:监听访问者与Service间的连接情况,如果成功连接,回调 onServiceConnected(),如果异常终止或者其他原因终止导致Service与访问者断开 连接则回调onServiceDisconnected方法,调用unBindService()不会调用该方法!
原文地址:https://www.cnblogs.com/sunupo/p/15505431.html