2
\$\begingroup\$

I currently program a game in which the user don't need to interact with the screen. Is there any way to keep the screen awake?

\$\endgroup\$
3
\$\begingroup\$

One option is to use a wake lock. Example from the docs:

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
wl.acquire();

// screen and CPU will stay awake during this section

wl.release();

I've got this answer from this stack overflow post. For detailed information go there.

| improve this answer | |
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.