Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a game that uses the accelerometer to move a guy back and forth on the screen. After a few seconds the screen goes dim. Is there any way to keep it alive and bright during the game activity?

share|improve this question

With the PowerManager API, you can acquire and release locks to:

  • prevent your device to pause;
  • prevent your device to dim;
  • force brightness
  • ...

Warning you must add one permission:

<uses-permission android:name="android.permission.WAKE_LOCK" />
share|improve this answer

I try like that in oncreate on activity start

share|improve this answer

This blog post covers the three ways of achieving this:

Basically, you either:

  • tell android through your layout xml that you want to keep the screen alive
  • tell android through a call to window manager to keep the screen on during oncreate
  • use wakelocks to force the device to use full power at all time (and drain batteries)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.