diff --git a/README.md b/README.md index 2e49f65..c134713 100644 --- a/README.md +++ b/README.md @@ -9,19 +9,19 @@ The Mqtt Android Service is an MQTT client library for developing applications o **Step 1.** Add it in your root **build.gradle** at the end of repositories: ```groovy - allprojects { - repositories { - ... - maven { url 'https://jitpack.io' } - } - } +allprojects { + repositories { + ... + maven { url 'https://jitpack.io' } + } +} ``` **Step 2.** Add the dependency: ```groovy dependencies { - implementation 'com.github.shiyinghan:MqttAndroid:1.0.0' - } + implementation 'com.github.shiyinghan:MqttAndroid:1.0.0' +} ``` diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8bc81fb..2ce5515 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -22,7 +22,8 @@ + android:launchMode="singleTask" + android:screenOrientation="portrait"> @@ -31,9 +32,11 @@ diff --git a/mqtt/src/main/java/com/shiyinghan/mqtt/android/service/MqttAndroidClient.java b/mqtt/src/main/java/com/shiyinghan/mqtt/android/service/MqttAndroidClient.java index 2708cd9..9a2b2f4 100644 --- a/mqtt/src/main/java/com/shiyinghan/mqtt/android/service/MqttAndroidClient.java +++ b/mqtt/src/main/java/com/shiyinghan/mqtt/android/service/MqttAndroidClient.java @@ -1649,7 +1649,7 @@ public void onFailure(IMqttToken asyncActionToken, Throwable exception) { synchronized void notifyOffline() { traceDebug(TAG, "Offline with client:" + getClientId() + '/' + getServerURI()); - if (callback != null && !connectOptions.isCleanSession()) { + if (isConnected() && callback != null && !connectOptions.isCleanSession()) { Exception e = new Exception("Android offline"); callback.connectionLost(e); }