Androidで外部サービス(別のjarにある)ファイルをバインド解除する適切な方法は何ですか?
org.eclipse.paho.android.service-1.0.2.jar
マニフェスト ファイルでサービス ( にある) を次のように宣言します。
<service android:name="org.eclipse.paho.android.service.MqttService" >
</service>
サービスソースはこちら
そして、サービスは適切に実行されます。ただし、アプリを終了するとエラーが発生し、検索を行った後、アクティビティのメソッド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
ただし、サービスを手動で開始するわけではないため、ServiceConnection
渡す必要はありません。unbindService()
そのサービスを取得してServiceConnection
バインドを解除する方法はありますか?