aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-19 17:31:28 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-19 17:31:28 +0100
commitcbf42ee12cb214e801a0e8473bae93935f70e394 (patch)
treef8ded14b89816ed47de9b04ab2083bccf7fc2733
parent4b9a507633d402a1eb344331c03c80f7a6369e9f (diff)
some saftey checks before registering listeners in XmppActivity
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index e6e97da39..2ff317a4b 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -1,6 +1,7 @@
package eu.siacs.conversations.ui;
import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
@@ -29,6 +30,7 @@ import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.nfc.NfcEvent;
import android.os.AsyncTask;
+import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.preference.PreferenceManager;
@@ -107,7 +109,7 @@ public abstract class XmppActivity extends Activity {
XmppConnectionBinder binder = (XmppConnectionBinder) service;
xmppConnectionService = binder.getService();
xmppConnectionServiceBound = true;
- if (!registeredListeners) {
+ if (!registeredListeners && shouldRegisterListeners()) {
registerListeners();
registeredListeners = true;
}
@@ -134,6 +136,15 @@ public abstract class XmppActivity extends Activity {
}
}
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
+ protected boolean shouldRegisterListeners() {
+ if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ return !isDestroyed() && !isFinishing();
+ } else {
+ return !isFinishing();
+ }
+ }
+
public void connectToBackend() {
Intent intent = new Intent(this, XmppConnectionService.class);
intent.setAction("ui");