AtanuCSE
AtanuCSE

Reputation: 8940

Always keep light on and disable phone lock - Phonegap

I'm developing an app using Cordova / Phonegap. I don't want the phone to turn off the light or lock itself.

My app needs the always light-on or never-lock mode functionality.

How can I achieve that in Phonegap application?

I searched for these functionality, found nothing. Do I need to write separate code for separate type of devices? Please help.....

Upvotes: 2

Views: 1875

Answers (1)

Keya
Keya

Reputation: 849

In Android you do this by adding following attribute in your layout:

    android:keepScreenOn="true"

You can add this to your root element.

I haven't used the PhoneGap for Android but you can try this:

Add the following permission in your Manifest:

"android.permission.WAKE_LOCK"

Then in your activity add:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

Upvotes: 1

Related Questions