Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
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?
2,75133 gold badges2727 silver badges5151 bronze badges
asked Oct 13, 2010 at 17:32
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" />
answered Oct 13, 2010 at 18:25
3,6261818 silver badges2828 bronze badges
I try like that in oncreate on activity start
answered Nov 2, 2012 at 6:16
15111 silver badge44 bronze badges
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)
answered Nov 2, 2012 at 6:38
Jari KomppaJari Komppa
7,82333 gold badges2929 silver badges6262 bronze badges
You must log in to answer this question.