mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2024-12-23 05:47:35 +00:00
Some more improvements to fix #325
This commit is contained in:
parent
6b522e9832
commit
4c157f4509
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user