0
我想從我的應用程序中以編程方式輸入「enter」鍵事件。無法在我的應用程序內輸入「enter」鍵事件android
我已經嘗試過使用abd shell命令以及使用AccessibilityService,但發現它沒有運氣。
Similar question was asked here as well
下面是我的代碼,我用來執行ADB shell命令:
try {
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec("input keyevent 66");
BufferedReader standardIn = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader errorIn = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String output = "";
String line;
while ((line = standardIn.readLine()) != null) {
output += line + "\n";
}
while ((line = errorIn.readLine()) != null) {
output += line + "\n";
}
Log.d("output", "" + output);
} catch (IOException e) {
e.printStackTrace();
}
我得到以下輸出:
sh: resetreason: can't execute: Permission denied
有人請幫助我。
如果有人知道如何使用AccessibilityService實現它,請讓我知道。
在此先感謝!
添加了上述權限,但仍然引發相同的輸出錯誤。 – Wazz
我認爲上面的權限和上面的代碼只適用於根目錄的設備。 – Wazz