Use wake locks
When it's necessary, you can use wake locks to keep the device from going to
sleep.
Under some circumstances, you may need to keep the device awake even when your
app is in the background. To do this, you can create a wake lock .
Note: Creating and holding wake locks can have a dramatic impact on the device's
battery life. You shouldn't use wake locks if there are any suitable
alternatives. For other options, see the
Choose the right API to keep the device awake
documentation. If you do need to use a wake lock, make sure to hold it for as
short a time as possible.
This guide explains the following areas:
This guide assumes you're familiar with the following topics:
Content and code samples on this page are subject to the licenses described in the Content License . Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-25 UTC.
[null,null,["Last updated 2025-02-25 UTC."],[],[]]