- levelAndFlags
- Combination of wake lock level and flag values defining the requested behavior of the WakeLock.
- tag
- Your class name (or other tag) for debugging purposes.
Documentation for this section has not yet been entered.
Creates a new wake lock with the specified level and flags.
The levelAndFlags parameter specifies a wake lock level and optional flags combined using the logical OR operator.
The wake lock levels are: PowerManager.PARTIAL_WAKE_LOCK, PowerManager.FULL_WAKE_LOCK, PowerManager.SCREEN_DIM_WAKE_LOCK and PowerManager.SCREEN_BRIGHT_WAKE_LOCK. Exactly one wake lock level must be specified as part of the levelAndFlags parameter.
The wake lock flags are: PowerManager.ACQUIRE_CAUSES_WAKEUP and PowerManager.ON_AFTER_RELEASE. Multiple flags can be combined as part of the levelAndFlags parameters.
Call NoType:android/os/PowerManager$WakeLock;Href=../../../reference/android/os/PowerManager.WakeLock.html#acquire() on the object to acquire the wake lock, and NoType:android/os/PowerManager$WakeLock;Href=../../../reference/android/os/PowerManager.WakeLock.html#release() when you are done.
java Example
PowerManager pm = (PowerManager)mContext.getSystemService( Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock( PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG); wl.acquire(); // ... do work... wl.release();
Although a wake lock can be created without special permissions, the NoType:android/Manifest$permission;Href=../../../reference/android/Manifest.permission.html#WAKE_LOCK permission is required to actually acquire or release the wake lock that is returned.
If using this to keep the screen on, you should strongly consider using Android.Views.WindowManagerLayoutParams.FLAG_KEEP_SCREEN_ON instead. This window flag will be correctly managed by the platform as the user moves between applications and doesn't require a special permission.