Simulating power button press to display switch off dialog box
问题 I am trying to invoke the switch off dialog box that appears when we press power button. But i want to accomplish this task from an android application or a Junit test case. I will choose the most feasible approach in this case. I have been trying to do this but was not able to succeed. I am trying to use the following five approaches: First approach: long eventTime = SystemClock.uptimeMillis(); boolean dispateched = launcherButtonWInst.dispatchKeyEvent(new KeyEvent(eventTime, eventTime,