Added in API level 33

WakeLockStateListener


interface WakeLockStateListener
android.os.PowerManager.WakeLockStateListener

A listener interface to get notified when the wakelock is enabled/disabled.

Summary

Public methods
abstract Unit

Frameworks could disable the wakelock because either device's power allowlist has changed, or the app's wakelock has exceeded its quota, or the app goes into cached state.

Public methods

onStateChanged

Added in API level 33
abstract fun onStateChanged(enabled: Boolean): Unit

Frameworks could disable the wakelock because either device's power allowlist has changed, or the app's wakelock has exceeded its quota, or the app goes into cached state.

This callback is called whenever the wakelock's state has changed.

Parameters
enabled Boolean: true is enabled, false is disabled.