-1

Is it possible on an Android terminal tou run a simple script? I'd like to run the following commands

$su
$cd /Downloads
Roman Kiselenko
  • 43,210
  • 9
  • 91
  • 103
KostasA
  • 5,204
  • 6
  • 23
  • 29

2 Answers2

1

Try something like this:

    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);
}

read this SO question also.

Community
  • 1
  • 1
droidev
  • 7,352
  • 11
  • 62
  • 94
0

Yes, search the app store for terminal emulator.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245