WakeLockManager
@UnstableApi
class WakeLockManager
Utility class to handle a WakeLock.
The handling of wake locks requires the WAKE_LOCK permission.
The class must be used from a single thread. This can be the main thread as all blocking operations are internally handled on the background Looper thread provided in the constructor.
Summary
Public constructors |
|---|
WakeLockManager(context: Context!, wakeLockLooper: Looper!, clock: Clock!)Creates the wake lock manager. |
Public functions |
|
|---|---|
Unit |
setEnabled(enabled: Boolean)Sets whether to enable the acquiring and releasing of the |
Unit |
setStayAwake(stayAwake: Boolean)Sets whether to acquire or release the |
Public constructors
Public functions
setEnabled
fun setEnabled(enabled: Boolean): Unit
Sets whether to enable the acquiring and releasing of the WakeLock.
By default, wake lock handling is not enabled. Enabling this will acquire the wake lock if necessary. Disabling this will release the wake lock if it is held.
setStayAwake
fun setStayAwake(stayAwake: Boolean): Unit
Sets whether to acquire or release the WakeLock.
Please note this method requires wake lock handling to be enabled through setEnabled(boolean enable) to actually have an impact on the WakeLock.