5

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.

Ali
  • 21,572
  • 15
  • 83
  • 95

2 Answers2

8

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.

Community
  • 1
  • 1
Grégory Jourdan
  • 367
  • 3
  • 12
-2

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

Alex Chengalan
  • 8,211
  • 4
  • 42
  • 56
  • This code acquire the wake lock so it wake up, I want to force the device to goes to sleep. – Ali Apr 16 '13 at 00:03