我使用Paho Android Service API
,我在onResume
中連接,並在中斷開連接。在運行時,我可以從設備上獲取subscribe
,並通過mosquitto Broker
查看來自PC的published
消息。當我按他BackButton
該應用程序crahses並顯示下面logcat
錯誤。當按下BackButton時,應用程序崩潰
請讓我知道如何解決這個問題。
到注意:
1_since我使用Paho Android Service API
我進口所需的庫到項目中。而
我的項目的清單文件的application
元素內我已經加入這一行
2_i不是在我的frament註冊任何接收器,在包括在庫接收我 進口使用泛美衛生組織API
<!-- Mqtt Service -->
<service android:name="org.eclipse.paho.android.service.MqttService" >
</service>
logcat的:
Activity com.example.mqtt_test_00.MessaginActivity
has leaked IntentReceiver [email protected] that was
originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity
com.example.mqtt_test_00.MessaginActivity has leaked IntentReceiver
[email protected] that was originally registered here.
Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.
<init>(LoadedApk.java:814)
at
android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:610)
at
android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1762)
at
android.app.ContextImpl.registerReceiver(ContextImpl.java:1742)
at
android.app.ContextImpl.registerReceiver(ContextImpl.java:1736)
at
android.content.ContextWrapper.registerReceiver(ContextWrapper.java:478)
at org
.eclipse.paho.android.service.MqttAndroidClient.registerReceiver(MqttAndroidClient.java:410)
at
org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:388)
at
com.example.mqtt_test_00.Sub_Frag$5.onClick(Sub_Frag.java:98)
android.app.ServiceConnectionLeaked: Activity
com.example.mqtt_test_00.MessaginActivity has leaked ServiceConnection
org.ecl[email protected]430756f0 that was
originally bound here
at android.app.LoadedApk$ServiceDispatcher.<init>
(LoadedApk.java:988)
at
org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:385)
at
com.example.mqtt_test_00.Sub_Frag$5.onClick(Sub_Frag.java:98)
取消註冊該服務,在壓倒之前,在onpause()方法中使用unregister – prakash 2014-11-21 12:43:05