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?
1 Answer
\$\begingroup\$
\$\endgroup\$
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.