pub struct Builder { /* private fields */ }
Expand description
A builder for configuring and creating a wake lock.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn level(self, level: Level) -> Self
pub fn level(self, level: Level) -> Self
Set the wake lock level.
Generally Level::Partial
wake locks are preferred, and is the
default level if not specified. See Level
for more information about
the different available wake lock levels.
Sourcepub fn acquire_causes_wakeup(self, acquire_causes_wakeup: bool) -> Self
👎Deprecated
pub fn acquire_causes_wakeup(self, acquire_causes_wakeup: bool) -> Self
Turn the screen on when the wake lock is acquired.
This flag requires Manifest.permission.TURN_SCREEN_ON
for apps
targeting Android version Build.VERSION_CODES#UPSIDE_DOWN_CAKE
and
higher.
Normally wake locks don’t actually wake the device, they just cause the screen to remain on once it’s already on. This flag will cause the device to wake up when the wake lock is acquired.
Android TV playback devices attempt to turn on the HDMI-connected TV via HDMI-CEC on any wake-up, including wake-ups triggered by wake locks.
Cannot be used with Level::Partial
.
§Deprecation
This option was deprecated in API level 33. Most applications should
use R.attr.turnScreenOn
or Activity.setTurnScreenOn(boolean)
instead, as this prevents the previous foreground app from being resumed
first when the screen turns on.
Sourcepub fn on_after_release(self, on_after_release: bool) -> Self
pub fn on_after_release(self, on_after_release: bool) -> Self
When this wake lock is released, poke the user activity timer so the screen stays on for a little longer.
This will not turn the screen on if it is not already on.
Cannot be used with Level::Partial
.