我正在使用Paho Android Service API
,我连接onResume
和断开连接onPause
。在运行时,我可以subscribe
从设备published
上通过mosquitto Broker
. 当我按下他时BackButton
,应用程序崩溃并显示以下logcat
错误。
请让我知道如何解决这个问题。
注意:
1_因为我正在使用Paho Android Service API
我将所需的库导入到项目中。
在我的项目清单文件的元素application
中,我添加了这一行
2_我没有在我的框架中注册任何接收器,接收器包含在我导入以使用 Paho API 的库中
<!-- Mqtt Service -->
<service android:name="org.eclipse.paho.android.service.MqttService" >
</service>
日志猫:
Activity com.example.mqtt_test_00.MessaginActivity
has leaked IntentReceiver org.eclipse.paho.android.service.MqttAndroidClient@43075698 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
org.eclipse.paho.android.service.MqttAndroidClient@43075698 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.eclipse.paho.android.service.MqttAndroidClient$MyServiceConnection@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 )