Ali
Ali

Reputation: 22317

Send android device to sleep mode

I want to test my app when the device is in sleep mode.

Screen off is not a good sign because the device may be on because of other things. I want to be sure that device is in sleep mode. Is there any command via ADB or other thing to send the device in sleep mode explicitly.

Upvotes: 5

Views: 9679

Answers (2)

Grégory Jourdan
Grégory Jourdan

Reputation: 417

According to this other thread (and I just checked): How to lock Android screen via ADB?

adb shell input keyevent 26

Does the trick! Good stuff.

Upvotes: 9

Alex Chengalan
Alex Chengalan

Reputation: 8281

may be this will help you.

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
     PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
     wl.acquire();
       ..screen will stay on during this section..
     wl.release();

more details are here

Upvotes: -2

Related Questions