android - 通过 UiAutomator 长按电源按钮

标签 android adb android-uiautomator

UiAutomator如何实现长按电源键(KeyEvent 26)获取电源菜单?

最佳答案

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

public void longPressHome(){
    long timeout = Configurator.getInstance().getActionAcknowledgmentTimeout();
    Configurator.getInstance().setActionAcknowledgmentTimeout(0);
    mDevice.pressHome();
    mDevice.pressHome();
    Configurator.getInstance().setActionAcknowledgmentTimeout(timeout);
}

关于android - 通过 UiAutomator 长按电源按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37909053/

相关文章:

android - 如何让两种构建风格继承自 Android Studio 中的根风格?

android - 我可以使用Gradle在Android的调试版本中启用断言吗?

Android dumpsys Activity 输出格式

java - 通过 UI Automator 查看器中的资源 ID 识别 espresso 中的元素

android - 如何在模拟器上运行 UIAutomator?

android - 如何从所选联系人中检索公司名称

android - 手动将本地文件添加到“下载”应用

android - AudioRecord - 如何将数据放入缓冲区?

Android Studio 无线 ADB 错误 (10061)(电视)

android - UI Automator/Ui Automator2 : Scroll and find child UI Element in Recycler View