Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable screen lock when Cordova app is running

Tags:

cordova

I don't know where to start. I am searching for this from yesterday but didn't got any idea.

I have a Cordova android app. It is working fine but if user is not doing anything then screen get locked and app will go to background/pause.

I want to keep the phone stay awake when app is running.

Is there any plugins/example for the same?

like image 317
Roxx Avatar asked Sep 05 '25 20:09

Roxx


1 Answers

You can use this plugin in order to prevent device from falling asleep.

In order to achive that you can call this method:

window.plugins.insomnia.keepAwake()

And then, to enable it again, you have to use:

window.plugins.insomnia.allowSleepAgain()

Please look at the Github page for more details

like image 98
Ernesto Schiavo Avatar answered Sep 11 '25 03:09

Ernesto Schiavo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!