So I'm developing an application that will record a devices screen.
I am using Runtime.getRuntime
to execute commands.
So I discovered you can use adb shell screenrecord --bit-rate 8000000 --time-limit 15 /sdcard/demovideo.mp4
to record you devices screen via adb, so I did this.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageButton time_launch = (ImageButton) findViewById(R.id.r_1);
time_launch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Process process = null;
try {
process = Runtime.getRuntime().exec("screenrecord --bit-rate 8000000 --time-limit 5 /sdcard/video.mp4");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
}
});
}
}
But sadly, nothing is happening when I press the button, the video doesnt record at all. I tried looking around on the internet but nothing is helpful. Hopefully one of you guys can help me out.