Added in API level 33

PowerManager.WakeLockStateListener


public static interface PowerManager.WakeLockStateListener

android.os.PowerManager.WakeLockStateListener


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

Summary

Public methods

abstract void onStateChanged(boolean enabled)

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
public abstract void onStateChanged (boolean enabled)

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.