Prevent screen lock when dimming / standby when using Android app?

I am developing an application, and the last touch I need to put on prevents the screen from locking when the device goes into standby mode (the screen is off). The exact behavior of Google Navigation.

I am wondering what, programmatically, will I have to use to support this feature all the time when using the application?

+3
source share
2 answers

writing the following code to your xml file will prevent your screen lock

android:keepScreenOn="true"
+12
source

In onCreate of your activity after setContentView use this:

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

.

+2

All Articles