Tag Archives: screen timeout

How to prevent screen timeout in Android

There are several mechanisms available for Android applications to stop the phone’s screen from being turned off. These methods override the default ‘screen timeout’ behaviour of your phone (typically found under Settings -> Display), and will keep the screen on while your application is running.

I will be introducing two methods to stop the screen from being dimmed. The two methods provide means of accomplishing this depending on the current state of your application; i.e. whether it has an Activity on the foreground (visible on screen) or running on the background (as a Service).

  1. Use of FLAG_KEEP_SCREEN_ON option for your Activity.
  2. Use of a WakeLock.

Continue reading