Android Guides | Samples

Android.OS.PowerManager.WakeLock Class

A wake lock is a mechanism to indicate that your application needs to have the device stay on.

See Also: PowerManager+WakeLock

Syntax

[Android.Runtime.Register("android/os/PowerManager$WakeLock", DoNotGenerateAcw=true)]
public class PowerManager.WakeLock : Object

Remarks

A wake lock is a mechanism to indicate that your application needs to have the device stay on.

Any application using a WakeLock must request the android.permission.WAKE_LOCK permission in an <uses-permission> element of the application's manifest. Obtain a wake lock by calling PowerManager.NewWakeLock(WakeLockFlags,String).

Call PowerManager+WakeLock.Acquire to acquire the wake lock and force the device to stay on at the level that was requested when the wake lock was created.

Call PowerManager+WakeLock.Release when you are done and don't need the lock anymore. It is very important to do this as soon as possible to avoid running down the device's battery excessively.

[Android Documentation]

Requirements

Namespace: Android.OS
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.OS.PowerManager.WakeLock are listed below.

See Also: Object

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

[read-only]
IsHeldBoolean. Returns true if the wake lock has been acquired but not yet released.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

Acquire()
Acquires the wake lock.
Acquire(Int64)
Acquires the wake lock with a timeout.
Release()
Releases the wake lock.
Release(WakeLockFlags)
SetReferenceCounted(Boolean)
Sets whether this WakeLock is reference counted.
SetWorkSource(WorkSource)
Sets the work source associated with the wake lock.