长按Android内部应用程序

长按Android内部应用程序,android,adb,Android,Adb,我试图用ADB模拟Android设备上的长点击 我读了这本指南: 我知道它在Android的UI上工作,但在应用程序中不工作 特别是,我试图模拟在应用程序的文本字段上长时间点击。编辑:首先,您需要root用户。要在运行时请求root用户,请执行以下操作: public static Process requestPermission() { try { return Runtime.getRuntime().exec("su"); } catch (IOExcep

我试图用ADB模拟Android设备上的长点击

我读了这本指南:

我知道它在Android的UI上工作,但在应用程序中不工作


特别是,我试图模拟在应用程序的文本字段上长时间点击。

编辑:首先,您需要root用户。要在运行时请求root用户,请执行以下操作:

public static Process requestPermission() {
    try {
        return Runtime.getRuntime().exec("su");
    } catch (IOException e) {
        LOGGER.error("The phone needs root: ", e.getMessage());
        return null;
    }
}
然后:

命令和默认源为:

text <string> (Default: touchscreen)
keyevent [--longpress] <key code number or name> ... (Default: keyboard)
tap <x> <y> (Default: touchscreen)
swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
press (Default: trackball)
roll <dx> <dy> (Default: trackball)
文本(默认:触摸屏)
keyevent[--longpress]。。。(默认:键盘)
轻触(默认:触摸屏)
滑动[持续时间(毫秒)](默认:触摸屏)
按(默认值:轨迹球)
滚动(默认:轨迹球)

您可以找到“adb shell keyevent”命令

是否已将LongPressListener设置为textfield?问题是如何从adb向设备发送长点击。你的答案与此无关。是的,问题是关于从adb向设备发送长点击。但幸运的是,可以使用命令adb shell input touchscreen swipe x y x y 2000,其中2000为2000ms。我错了坐标(它们是相对的而不是绝对的)。谢谢大家!!!
text <string> (Default: touchscreen)
keyevent [--longpress] <key code number or name> ... (Default: keyboard)
tap <x> <y> (Default: touchscreen)
swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
press (Default: trackball)
roll <dx> <dy> (Default: trackball)