Struct Builder

Source
pub struct Builder { /* private fields */ }
Expand description

A builder for configuring and creating a wake lock.

Implementations§

Source§

impl Builder

Source

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.

Source

pub fn acquire_causes_wakeup(self, acquire_causes_wakeup: bool) -> Self

👎Deprecated

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.

Source

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.

Source

pub fn build(&self) -> Result<WakeLock, Error>

Creates a new wake lock with the specified level and options.

Trait Implementations§

Source§

impl Clone for Builder

Source§

fn clone(&self) -> Builder

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Builder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.