ᴘᴀɴ*_*ᴛɪs 5 java service android paho
在Android中取消绑定外部服务(位于另一个jar)文件的正确方法是什么?
我org.eclipse.paho.android.service-1.0.2.jar将清单文件中的服务(位于)声明为:
<service android:name="org.eclipse.paho.android.service.MqttService" >
</service>
Run Code Online (Sandbox Code Playgroud)
服务来源在这里
服务运行正常.但是,在退出应用程序时,我收到一个ServiceConnectionLeaked错误,在进行一些搜索后,我发现我需要调用活动unbindService(...);的onDestroy()方法.
日志:
24915-24915/com.testapp.testmqtt E/ActivityThread? Activity com.testapp.testmqtt.MainActivity has leaked ServiceConnection org.eclipse.paho.android.service.MqttAndroidClient$MyServiceConnection@426c50d8 that was originally bound here
android.app.ServiceConnectionLeaked: Activity com.testapp.testmqtt.MainActivity has leaked ServiceConnection org.eclipse.paho.android.service.MqttAndroidClient$MyServiceConnection@426c50d8 that was originally bound here
Run Code Online (Sandbox Code Playgroud)
但是,我没有ServiceConnection传递给unbindService()我,因为我没有手动启动该服务.有没有办法获得该ServiceConnection服务并取消绑定?
小智 11
我只是将此代码放在onDestroy活动中
client.unregisterResources();
client.close();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2855 次 |
| 最近记录: |