Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Quando necessario, puoi utilizzare i blocchi di riattivazione per impedire al dispositivo di andare in
sospensione.
In alcune circostanze, potrebbe essere necessario mantenere attivo il dispositivo anche quando l'app è in background. Per farlo, puoi creare un wake lock.
Il tuo feedback è fondamentale per migliorare la nostra documentazione. Inviaci
il tuo feedback utilizzando il seguente link:
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-08-27 UTC.
[null,null,["Ultimo aggiornamento 2025-08-27 UTC."],[],[],null,["When it's necessary, you can use wake locks to keep the device from going to\nsleep.\n\nUnder some circumstances, you may need to keep the device awake even when your\napp is in the background. To do this, you can create a *wake lock*.\n\nYour feedback is a crucial part of improving our documentation. Please give us\nyour feedback using the following link:\n\n\n[Give feedback](https://docs.google.com/forms/d/e/1FAIpQLSc0OMFG-G88ZyHh_xwauaM2gimwP9-MFvRd6C49q0atZNpZ9w/viewform?usp=dialog)\n| **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](/develop/background-work/background-tasks/awake) documentation. If you do need to use a wake lock, make sure to hold it for as short a time as possible.\n\nThis guide explains the following areas:\n\n- [Set a wake lock](/develop/background-work/background-tasks/awake/wakelock/set)\n- [Release a wake lock](/develop/background-work/background-tasks/awake/wakelock/release)\n- [Follow wake lock best practices](/develop/background-work/background-tasks/awake/wakelock/best-practices)\n- [Debug wake locks locally](/develop/background-work/background-tasks/awake/wakelock/debug-locally)\n- [Identify wake locks created by other APIs](/develop/background-work/background-tasks/awake/wakelock/identify-wls)\n\nThis guide assumes you're familiar with the following topics:\n\n- [Choose the right API to keep the device awake](/develop/background-work/background-tasks/awake)\n- [Request runtime permissions](/training/permissions/requesting)"]]