cordova-plugin-background-mode
                                
                                 cordova-plugin-background-mode copied to clipboard
                                
                                    cordova-plugin-background-mode copied to clipboard
                            
                            
                            
                        On Android the app stays above the lock screen
When using this plugin and when the app is active and when powering off the screen (locking the phone) then the the app stays above the lock screen. For security reasons this is unwanted behavior.
Currently the only workaround is to listen for Cordova's pause event which is triggered when the power button is pressed and inside that event moveToBackground() has to be called. However such behavior isn't user friendly and not so reliable either. For example I have noticed that pause events are sometimes triggered on the app startup.
I can confirm this. Another unwanted behavior us that if you have excluded the app from the recents list and you use it, after 15 seconds (or whatever your screen lock timer is), the phone will lock behind the app, as if the screen is off. Hitting the home button then will ask you to unlock.
I'm having this issue as well but it's not this plugin. I believe it has something to do with the android platform itself. I upgraded from 6.2.3 to 6.4.0 and started to see this happen. Has anyone figured anything out yet?
I belive it has to do with these flags being added to the window: BackgroundExt.java Line 294
See also this stackoverflow post.
This is a very dangerous default behaviour which should be fixed imho, because a security sensitive application may use this plugin without the developer knowing about this behaviour!
I am not an android developer myself or otherwise i would fix it
Yup removing the flags fixes this bug. The problem is that most likely another feature (which i am not using) is going to break because of the change so i am not creating a merge request for now.
My fork: https://github.com/derrohrbach/cordova-plugin-background-mode
I guess these flags are necessary for supporting wakeUp() and unlock().
I would propose, to require developers who want to use these functions/features, that they need to configure this before invoking the functions, e.g.
cordova.plugins.backgroundMode.enableWakeUp(true);
cordova.plugins.backgroundMode.enableUnlock(true);
and then set/update the window-flags accordingly.
So if not explicitly enabled, these flags should not be applied to the window.
Any new about this?
You can use my fork if you do not need the unlock/above lockscreen/turn screen on functionality
Unfortunately that's my case. I am trying another solution and, if a found something I'll post it here. If anyone have other suggestion it'll be appreciated.
if you only need the wake-up feature (i.e. not unlock), you could try my branch: https://github.com/mmig/cordova-plugin-background-mode/tree/issue325_configure-wakeup-unlock
you'd need to enable the the feature you want to use first,e.g.
cordova.plugins.backgroundMode.enableWakeUp();
   //...
cordova.plugins.backgroundMode.wakeUp();
This only sets the flag FLAG_TURN_SCREEN_ON, and not the others that are required for the unlock feature.
The drawback is that right now, the feature cannot be disabled once enabled
(if you want to use unlock: this feature requires all the window-flags set, so once it is enabled, it will behave same as the original plugin)
@lkonzen-garupa did you find any solution?
@Manja14 if you want to use the unlock() feature, then you have to life with this:
putting the app "above the lock-screen" is how this plugin accomplishes the unlock (without the user needing to enter her/his password etc).
If you do not need the unlock() feature, you can use @derrohrbach's or my solution/branch
I hope its fixed now by using the master branch.
I hope its fixed now by using the master branch.
It seem not resolved in version 0.7.2, for my application this is a very unwanted and annoying behaviour, it should be conditionally enabled and disabled in some way.
Maybe the official cordova plugin didnt yet received the fix? how to install a fixed version in cordova?
@LucaColombi
cordova plugin add https://github.com/katzer/cordova-plugin-background-mode.git
Hello guys, That's weird ... but i want that to happen. I want my app staying above the lockscreen ... how can i perform it? Actually i'm just calling cordova.plugins.backgroundMode.enable(); What i need to call next in order to make the app staying above the lockscreen? Thanks in advance