Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Keep the Screen On

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 312
    Comment on it

    There are certain situations when we need to turn screen ON such as live map games, routing, movie, tv apps.

    Basically, to avoid battery draining android device fall asleep after some time, but to accomplish this task we have to keep screen ON.

    We can do it from both Activity as well as from XML.

    From Activity:

    We use WindowManager class by using FLAG_KEEP_SCREEN_ON property.


    public class MainActivity extends Activity {
      protected void onCreate(Bundle savedInstanceState) {

    From XML:

    By using keepScreenOn attribute

    <RelativeLayout xmlns:android=""


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: