Android UiAutomator长按电源按钮

Android UiAutomator长按电源按钮,android,adb,android-uiautomator,Android,Adb,Android Uiautomator,按下电源按钮(KeyEvent 26)多长时间可通过UiAutomator获得电源菜单?解决此问题- 请试用这个工具。。记录长按电源按钮的时间。并使用工具运行。或者将xxx.mes文件推送到电话,然后运行adb shell sh xxx.mes单独运行。 我在Galaxy s6上测试过,效果很好。如果您遇到任何问题,请在这里发表评论。我可以解决这个问题 您可以从uiautomator调用adb shell shcomamnd。来解决此问题- 请试用这个工具。。记录长按电源按钮的时间。并使用工具运

按下电源按钮(KeyEvent 26)多长时间可通过UiAutomator获得电源菜单?

解决此问题- 请试用这个工具。。记录长按电源按钮的时间。并使用工具运行。或者将xxx.mes文件推送到电话,然后运行
adb shell sh xxx.mes
单独运行。 我在Galaxy s6上测试过,效果很好。如果您遇到任何问题,请在这里发表评论。我可以解决这个问题

您可以从uiautomator调用
adb shell sh
comamnd。

来解决此问题- 请试用这个工具。。记录长按电源按钮的时间。并使用工具运行。或者将xxx.mes文件推送到电话,然后运行
adb shell sh xxx.mes
单独运行。 我在Galaxy s6上测试过,效果很好。如果您遇到任何问题,请在这里发表评论。我可以解决这个问题


您可以从uiautomator调用
adb shell sh
comamnd。

下面,这是一个长按home按钮的解决方案,它可以工作。也许您可以尝试使用power KeyCode而不是mDevice.pressHome()


下面是长按home按钮的解决方案,它可以工作。也许您可以尝试使用power KeyCode代替mDevice.pressHome()


我使用反射解决了这个问题:

Class<?> clazz = mDevice.getClass();
Method getUiAutomation = clazz.getDeclaredMethod("getUiAutomation");
getUiAutomation.setAccessible(true);

((UiAutomation) getUiAutomation.invoke(mDevice)).performGlobalAction(GLOBAL_ACTION_POWER_DIALOG);
Class clazz=mDevice.getClass();
方法getUiAutomation=clazz.getDeclaredMethod(“getUiAutomation”);
getUiAutomation.setAccessible(true);
((UiAutomation)getUiAutomation.invoke(mDevice)).performGlobalAction(全局操作动力对话框);

我使用反射解决了这个问题:

Class<?> clazz = mDevice.getClass();
Method getUiAutomation = clazz.getDeclaredMethod("getUiAutomation");
getUiAutomation.setAccessible(true);

((UiAutomation) getUiAutomation.invoke(mDevice)).performGlobalAction(GLOBAL_ACTION_POWER_DIALOG);
Class clazz=mDevice.getClass();
方法getUiAutomation=clazz.getDeclaredMethod(“getUiAutomation”);
getUiAutomation.setAccessible(true);
((UiAutomation)getUiAutomation.invoke(mDevice)).performGlobalAction(全局操作动力对话框);

这可能会给您一些想法-电源按钮是一个硬按钮,在您的示例中,在Ui设备上长按虚拟按钮。这可能会给您一些想法-电源按钮是一个硬按钮,在您的示例中,在Ui设备上长按虚拟按钮。