解除绑定外部服务 android Paho MQTT ServiceConnectionLeaked 错误

Unbind external service android Paho MQTT ServiceConnectionLeaked error

在 Android 中取消绑定外部服务(位于另一个 jar 中)文件的正确方法是什么?

我在清单文件中将服务(位于 org.eclipse.paho.android.service-1.0.2.jar)声明为:

<service android:name="org.eclipse.paho.android.service.MqttService" >
</service>

服务来源here

服务正常运行。但是,在退出应用程序时,我收到 ServiceConnectionLeaked 错误,经过一些搜索后,我发现我需要在 activity 的 onDestroy() 方法上调用 unbindService(...);

日志:

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

但是,我没有要传递给 unbindService()ServiceConnection,因为我没有手动启动该服务。有没有办法获取那个服务的ServiceConnection并解除绑定?

我只是把这段代码放在 activity

的 onDestroy 中
    client.unregisterResources();
    client.close();