From 0fbbf8c20ece1586a119fd4accc962fe73b5b268 Mon Sep 17 00:00:00 2001 From: 陈力 <chenli@lotaai.com> Date: 星期三, 14 六月 2023 19:31:46 +0800 Subject: [PATCH] bug --- app/src/main/java/com/lotaai/canguiayw/mqtt/MyMQTTService.java | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/lotaai/canguiayw/mqtt/MyMQTTService.java b/app/src/main/java/com/lotaai/canguiayw/mqtt/MyMQTTService.java index 4d8c0b2..1a0324a 100644 --- a/app/src/main/java/com/lotaai/canguiayw/mqtt/MyMQTTService.java +++ b/app/src/main/java/com/lotaai/canguiayw/mqtt/MyMQTTService.java @@ -55,7 +55,9 @@ @Override public int onStartCommand(Intent intent, int flags, int startId) { init(); - EventBus.getDefault().register(MyMQTTService.this); + if (!EventBus.getDefault().isRegistered(MyMQTTService.this)) { + EventBus.getDefault().register(MyMQTTService.this); + } return super.onStartCommand(intent, flags, startId); } @@ -81,7 +83,7 @@ // 服务器地址(协议+地址+端口号) String uri = "tcp://" + SettingConfig.getInstance().MQTT_IP+":"+SettingConfig.getInstance().MQTT_PORT;; LogUtils.i(uri); - client = new MqttAndroidClient(this, uri, CacheDiskUtils.getInstance().getString(SettingConfig.getInstance().Cache_Device_Code)); + client = new MqttAndroidClient(this, uri, CacheDiskUtils.getInstance().getString(SettingConfig.getInstance().Cache_Device_Code)+"houping"); // 设置MQTT监听并且接受消息 client.setCallback(mqttCallback); conOpt = new MqttConnectOptions(); -- Gitblit v1.7.1