Search This Blog

Showing posts with label PowerManager. Show all posts
Showing posts with label PowerManager. Show all posts

Wednesday, December 26, 2012

Keep screen on when the Activity running using power manager


First of all make the object of the Power manage.

protected PowerManager.WakeLock mWakeLock;


Now in onCreate method use the following to make the screen ON in the particular activity.

final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
this.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "My Tag");
this.mWakeLock.acquire();