简体   繁体   中英

Error receiving broadcast Intent?

Below is my BroadcastReceiver code where I'm getting this error:

java.lang.RuntimeException: Error receiving broadcast Intent { act=org.mosquitto.android.powerviewer.PING flg=0x4 (has extras)  

My code:

public class PingSender extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent) {
        context2 = context;

        try {
            System.err.println("MQTT IS NULLLLLLLLLLLLL");
            mqttClient.ping();
        } catch (MqttException e) {

            Log.e("mqtt", "ping failed - MQTT exception", e);

            try {
                mqttClient.disconnect();
            } catch (MqttPersistenceException e1) {
                Log.e("mqtt", "disconnect failed - persistence exception", e1);
            }

            // reconnect
            if (connectToBroker()) {
                String deviceID = mPrefs.getString(PREF_DEVICE_ID, null);
                ;
                deviceID = MQTT_CLIENT_ID + "/" + deviceID;
                subscribeToTopic(deviceID);
            }
        }

        // start the next keep alive period
        scheduleNextPing();
    }
}

找出是否要覆盖任何Android生命周期事件,并按要求正确调用基类构造函数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM