power Manager
A convenient inline property to retrieve the PowerManager system service.
This property provides a shorthand way to access the PowerManager instance associated with the current Context. The PowerManager allows you to control the device's power state, such as managing wake locks, detecting whether the screen is on, and checking power-saving modes.
Return
The PowerManager instance, or null if the system service is not available.
See also
Throws
if the system service is not of type PowerManager (highly unlikely).
Example Usage:
val isScreenOn = if(powerManager?.isInteractive == true){
//Screen is on
}else {
//Screen is off
}Content copied to clipboard