diff --git a/src/android/BackgroundExt.java b/src/android/BackgroundExt.java index 9f27859..4c34a46 100644 --- a/src/android/BackgroundExt.java +++ b/src/android/BackgroundExt.java @@ -147,6 +147,7 @@ class BackgroundExt { Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); + clearSreenAndKeyguardFlags(); app.startActivity(intent); } @@ -244,10 +245,8 @@ class BackgroundExt { */ private void unlock() { - getApp().runOnUiThread(() -> { - addSreenAndKeyguardFlags(); - getApp().startActivity(getLaunchIntent()); - }); + addSreenAndKeyguardFlags(); + getApp().startActivity(getLaunchIntent()); } /** @@ -287,7 +286,15 @@ class BackgroundExt { */ private void addSreenAndKeyguardFlags() { - getApp().getWindow().addFlags(FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | FLAG_SHOW_WHEN_LOCKED | FLAG_TURN_SCREEN_ON | FLAG_DISMISS_KEYGUARD); + getApp().runOnUiThread(() -> getApp().getWindow().addFlags(FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | FLAG_SHOW_WHEN_LOCKED | FLAG_TURN_SCREEN_ON | FLAG_DISMISS_KEYGUARD)); + } + + /** + * Clears required flags to the window to unlock/wakeup the device. + */ + private void clearSreenAndKeyguardFlags() + { + getApp().runOnUiThread(() -> getApp().getWindow().clearFlags(FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | FLAG_SHOW_WHEN_LOCKED | FLAG_TURN_SCREEN_ON | FLAG_DISMISS_KEYGUARD)); } /**