Execute A Shell Command Programmatically: Why It Doesn't Work?
I'm trying to programmatically execute the new command 'ScreenRecorder' kitkat. I just tried this: suProcess = Runtime.getRuntime().exec('su'); process = Runtime.getRuntime().exec(
Solution 1:
Try this
public static void ScreenRecord() throws Exception
{
try
{
Process su = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
outputStream.writeBytes("screenrecord --time-limit 10 /sdcard/MyVideo.mp4\n");
outputStream.flush();
outputStream.writeBytes("exit\n");
outputStream.flush();
su.waitFor();
}
catch(IOException e)
{
throw new Exception(e);
}catch(InterruptedException e){
throw new Exception(e);
}
}
Solution 2:
It doesn't work because it's an emulator and not a normal device. I think this article could help in this case: http://russelldavis.blogspot.com/2011/01/rooting-android-emulator.html
Post a Comment for "Execute A Shell Command Programmatically: Why It Doesn't Work?"