How to Prevent Screen Turning off

To make an app that does not turn off the screen after inactive for some time, add the property


android:keepScreenOn="true"

to yout layout XML resource. If you want the phone stop turning off the screen when a particular view is visible, Add this to your view


<RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:keepScreenOn="true">

As long as that view is visible, the screen of the phone will be turned off.

Comments

Popular Posts