Skip to main content

Overview

Releases a previously acquired wake lock. This allows the Android system to suspend the CPU when idle. Always call this method when your background work is complete to preserve battery life.

Returns

success
boolean
Promise resolving to true if the wake lock was successfully released, false if no wake lock was held or release failed.

Platform Behavior

Important Notes

  • Always Release: Call releaseWakeLock() after your background work is complete to avoid draining battery.
  • Safe to Call: It’s safe to call this method even if no wake lock is held - it will return true.
  • Use Finally Blocks: Consider using finally blocks to ensure wake locks are always released.
  • One-to-One Mapping: Each acquireWakeLock() call should have a corresponding releaseWakeLock() call.

When to Call

Do call releaseWakeLock() when:
  • Background work is complete
  • An error occurs during background processing
  • The component unmounts
  • The app enters the background (if work is complete)
Don’t call releaseWakeLock() when:
  • Background work is still ongoing
  • You haven’t called acquireWakeLock() first

Example Usage

Basic Usage

With Try-Finally

In a React Component

With Error Handling

Checking Before Release