Archivi tag: prorammazione

[ANDROID] Screen always turned on How to

This android code snippet is for keep alive the screen of your android device during the execution of your app, please read the note also.

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

..screen will stay on during this section..

wl.release();

IMPORTANT: Remember to RELEASE the WakeLock when you have finished to use it, otherwise the screen will be ever turned on! 🙂