Prevent Screen Lock


#1

Hi

I’m writing a little app for glider pilots, however, it’s important that while the app is running, the screen lock is disabled to prevent having to type the unlock key when waking up the device.

To do so, I guess it’s necessary to somehow modify the device settings programatically. Is there a way to do so? (I’m primarily asking for Android, but a universal approach would be even better.)

Thanks for your hints!


#2

With the app in the foreground you can prevent it falling asleep by using the nativescript-insomnia plugin.


#3

That’s not what I mean and therefore insomnia is no solution.

I want the phone to fall asleep to conserve battery power. The phone is then woken up with WaveUp or dt2w, displaying the relevant information and then the phone falls asleep again. However, when waking up the phone, the lock must be disabled since otherwise the pilot would have to e.g. type in the PIN during flight – not a good idea.

So I’m looking for a way to temporary disable the lock (PIN, pattern, whatever) while the app is active and then re-establish the previous lock setting once the app is quit by the user.