Some users of my Android application report bugs when the mobile enters sleep/power saving mode.
I would like to test that issue on the Android Virtual Device. Is it possible to simulate the mobile entering in sleep/power saving mode on the AVD ?
Thanks in advance.
Try the following on emulator
- Go to
Settings
- Go to
Developer options
- Un-check
Stay awake
(3rd option from the top)
The emulator will go to sleep after 1 min (default setting) if not changed.
Press the power button to wake up the emulator.
Developer options
is not enabled by default, to enable it, do the following:
- Go to
Settings
- Click
About emulated device
- Click
Build number
7 times, you should be notified that Developer options
is now enabled
- Go back and you should see
Developer options
The Power Button
on the sidebar next to emulator will do it.
The hotkey on my Mac is ⌘ P
Note: You will need to set Lock Screen using Swipe instead of None
On emulator, go Settings/Security/Screen lock change from 'None' to 'Swipe'
Then, click 'power' button on right control bar to turn off screen, and press again to turn on screen. Now the lock screen will show up.
Somehow fn + F7 doesn't work on my mac. So what I use instead is:
adb shell input keyevent 26
This sends the POWER KEY event and will turn off the screen. Note: It will not show that the screen is off. Image wills tay. But you can't interact with it. As soon as you do adb shell input keyevent 26
again, you will see the lock screen indicating, that the device was off before.
By pressing F7 you can emulate sleep mode in your emulator.