2

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.....

AtanuCSE
  • 8,832
  • 14
  • 74
  • 112

1 Answers1

1

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);
Dinesh Prajapati
  • 9,274
  • 5
  • 30
  • 47
Keya
  • 859
  • 3
  • 9
  • 17
  • 2
    Thanks for you reply bro, I know it'll work for android. I've seen this before. But I was expecting more like Phonegap solution, so that all devices(iphone/android) can be handled with single piece of code.Lets see if any other answers came. – AtanuCSE Feb 11 '14 at 07:39