1
をAndroid
デバイスで実行する方法Java
からscreenrecording
のデバイスを実行するにはどうすればよいですか?Androidデバイスでadb screenrecordをJavaから実行し、screenrecordingを終了する方法はありますか?
現在、録音を終了するには--time-limit
を指定する必要があります。終了する前にビデオをキャプチャしようとすると、失敗します。
録音を停止するようにadbに指示する方法はありますか? shell
コマンドにCTRL-C
を送信するようにスレッドを設定する方法はありますか?
これは、ルーティングされていない電話機で実行されます。
コード
videoExecutor.submit(() -> {
//Start recording video
String recordVideo = "screenrecord --time-limit " + testRun.getVideoLength() + " " + "/sdcard/" + logDate + ".mp4";
try {
device.executeShell(recordVideo);
} catch (Exception e1) {
e1.printStackTrace();
}
sleep(testRun.getVideoLength()*ONE_SECOND + TWO_SECONDS); //gotta match the --time-limit above.
RemoteFile remote = new RemoteFile("/sdcard/" + logDate + ".mp4");
File local = new File(videoPath); //Save file to local machine
if(!local.getParentFile().exists()) {
local.getParentFile().mkdirs();
}
try {
//Copy video from phone to computer
try {
device.pull(remote, local);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
電話機はルートされていないので、killallへのアクセス権がないようです。 adbシェルkillall -q = 1 screenrecord/system/bin/sh:killall:見つからない – ALM
あなたはサーバー上のプロセスを強制終了していますか?私は電話でそれを殺すことを見ている。ロックされていないアンドロイド携帯のように見えますが、何か不足している場合を除き、殺したり殺したりすることはできません。 おかげ /システム/ binに/ SH:殺す:998:操作 – ALM
を許可されていない、あなたの 'pid'をダブルチェック - 同じユーザーID恐ろしい –