編集:まず、これにはrootが必要です。実行時にルートを求めて:その後
public static Process requestPermission() {
try {
return Runtime.getRuntime().exec("su");
} catch (IOException e) {
LOGGER.error("The phone needs root: ", e.getMessage());
return null;
}
}
:あなたは "adbのシェルのKeyEventは" here
コマンド見つけることができます
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)
:
Process process = SystemUtils.requestPermission();
DataOutputStream os = new DataOutputStream(process.getOutputStream());
cmd = "/system/bin/input swipe 100 1650 600 1650\n"; //Example
os.writeBytes(cmd);
os.writeBytes("exit\n");
os.flush();
os.close();
process.waitFor();
コマンドとデフォルトの源であります
LongPressListenerをtextfieldに設定しましたか? –