Stay organized with collections
Save and categorize content based on your preferences.
WakeLockStateListener
interface 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
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. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# PowerManager.WakeLockStateListener\n\nAdded in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nWakeLockStateListener\n=====================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/os/PowerManager.WakeLockStateListener \"View this page in Java\") \n\n```\ninterface WakeLockStateListener\n```\n\n|----------------------------------------------------|\n| [android.os.PowerManager.WakeLockStateListener](#) |\n\nA listener interface to get notified when the wakelock is enabled/disabled.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onStateChanged](#onStateChanged(kotlin.Boolean))`(`enabled:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` 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. |\n\nPublic methods\n--------------\n\n### onStateChanged\n\nAdded in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onStateChanged(enabled: Boolean): Unit\n```\n\nFrameworks 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.\n\nThis callback is called whenever the wakelock's state has changed.\n\n| Parameters ||\n|-----------|-------------------------------------------------------------------------------------------------------------------------|\n| `enabled` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): true is enabled, false is disabled. |"]]