最近在用mqtt做及时通信,mqtt服务本身是放在本地的service服务里面运行,在应用关闭的时候,mqtt服务也要断开连接,不然会继续占用服务器的cpu,增加服务器负担。所以,在service的onDestroy中,需要调用MqttAndroidClient.disconnect()方法,但是会出现如下报错Log:
Service org.eclipse.paho.android.service.MqttService has leaked IntentReceiver org.eclipse.paho.android.service.AlarmPingSender$AlarmReceiver@29e9a4b8 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Service org.eclipse.paho.android.service.MqttService has leaked IntentReceiver org.eclipse.paho.android.service.AlarmPingSender$AlarmReceiver@29e9a4b8 that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:903)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:704)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.ja