In this guide, we will show you the ADB Commands to prevent an Android device from sleeping. If you are a developer testing out a few things but the device tends to go to sleep after a few minutes, then it could lead to quite an infuriating experience apart from the break in the workflow.
In this regard, you have the option to change the time after which the device goes to sleep, but in most devices, the maximum time is 30 minutes, which might not be sufficient for most of you. So, is there a way to expand this time limit? Well, there is one, and in this guide, we will show you how to do just that. So without further ado, let’s get started.
Table of Contents
How to Prevent an Android Device from Sleeping via ADB Command
- Download and extract the Android SDK Platform Tools on your PC.
- Now enable USB Debugging and connect your device to PC via USB.
- Open Command Prompt inside the platform tools folder and type in
adb shell settings put global stay_on_while_plugged_in 3
- Likewise, you may also use the below command to get this job done:
adb shell svc power stayon true
- NOTE: You might have to keep your device plugged in for these commands to work.
How To Revert To The Default Setting
After executing either of the two above commands, your device will never sleep. So it’s highly recommended to bring your device back to its default sleep settings once you are done with the task. Here’s how it can be done:
- If you had used the adb shell settings put global stay_on_while_plugged_in 3 command, then type in the below command:
adb shell settings put global stay_on_while_plugged_in 0
- On the other hand, if you had used the adb shell svc power stayon true command, then execute the below-given command:
adb shell svc power stayon false
How to Prevent an Android Device from Sleeping ‘Without’ ADB Command
Yes, there does exist a method to get this job done without ADB Commands, and trust us, it’s the easier and shorter one when compared with its counterpart. The command that we had used earlier adb shell svc power stayon true is just the equivalent of setting to keep the device awake while plugged in. So you can simply enable this toggle in one go and achieve the same result that the ADB Command gave you. To do so, just head over to Settings > System > Developer Options > Enable Stay Awake.
That’s it. These were the steps to prevent an Android device from sleeping via ADB Commands. Likewise, we have also given the steps to revert the settings back to their default state. If you have any queries concerning the aforementioned steps, do let us know in the comments. We will get back to you with a solution as soon as possible.