Reputation: 53
I want to keep the the display on whilst the application is running, i.e. I don't want the device to get locked whilst the application is running.
Upvotes: 0
Views: 62
Reputation: 437
Instead of using wake-locks, you can also use:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Upvotes: 0
Reputation: 81
I think what you want is WakeLock. You should look to this: http://developer.android.com/reference/android/os/PowerManager.WakeLock.html
You need this permission: android.permission.WAKE_LOCK
Then you can just do something like this:
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "My Tag");
mWakeLock.acquire();
To remove the WakeLock just call:
mWakeLock.release();
Upvotes: 1
Reputation: 3453
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag");
wl.acquire();
Also need to add android.permission.WAKE_LOCK to manifest.
Upvotes: 0