Power Management

AndroidShutDown

Shut down the device.

public static void AndroidShutDown()

AndroidReboot

Reboot the device.

public static void AndroidReboot()

AcquireWakeLock

Acquire system wakelock,block device from sleeping.

public static void AcquireWakeLock(int wakeLockLevel = FORGROUND_WAKE_LOCK)

Parameter

Description

wakeLockLevel

  • BACKGROUND_WAKE_LOCK, CPU is running,backgound thread is running, but foreground Android app will be paused by the system. UnityMain event function such as Update() will be paused.

  • FORGROUND_WAKE_LOCK,keep foreground app running, and the power key is also blocked.

  • Default value:FORGROUND_WAKE_LOCK

ReleaseWakeLock

Release system wakelock to allow system go to sleep. Make sure all the acquired level are released to let the system go to sleep.

public static void ReleaseWakeLock(int wakeLockLevel = FORGROUND_WAKE_LOCK)

Parameter

Description

wakeLockLevel

  • BACKGROUND_WAKE_LOCK, release background wake lock.

  • FORGROUND_WAKE_LOCK,release foreground wake lock,allow power key event, when next time system go to sleep event happen, such as power key or p-sensor, foreground app will pause.

  • Default value:FORGROUND_WAKE_LOCK

Last updated