diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-11-23 14:58:54 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-11-23 14:58:54 +0100 |
commit | e5f2c9d1e918be11ac91c055ecc07dad9233c6d3 (patch) | |
tree | 191295dfeccb4e25f203f8062e93b0f716cc9db5 /src/main/java/de/pixart/messenger/services | |
parent | 437d88331d49d628b64909c74febceb3d2c0c372 (diff) |
catch a few run time exceptions related to androids life cycle mgmt
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 9fcb83aa5..7c5d2b64d 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -957,15 +957,18 @@ public class XmppConnectionService extends Service { @SuppressLint("NewApi") @SuppressWarnings("deprecation") public boolean isInteractive() { - final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - - final boolean isScreenOn; - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - isScreenOn = pm.isScreenOn(); - } else { - isScreenOn = pm.isInteractive(); + try { + final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); + final boolean isScreenOn; + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + isScreenOn = pm.isScreenOn(); + } else { + isScreenOn = pm.isInteractive(); + } + return isScreenOn; + } catch (RuntimeException e) { + return false; } - return isScreenOn; } private boolean isPhoneSilenced() { |