Andrei
Andrei

Reputation: 1005

Avoid android from shutting screen off while app (with Phonegap) is on

I'm programming an Android application, and I would like to do so that it doesn't shut down the screen, ever.Pretty much like a car gps app that keeps the screen on.

Would someone know how to do this with phonegap ?
If its not possible in Javascript, is there an easy way to do it in Java but inside the main Phonegap function ?

Thank you

Upvotes: 7

Views: 2828

Answers (1)

RajaReddy PolamReddy
RajaReddy PolamReddy

Reputation: 22493

use this property in the ManiFestFile

<uses-permission android:name="android.permission.WAKE_LOCK"/>

and add this in the required Activity

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

Upvotes: 15

Related Questions