简体   繁体   中英

Unable to record video using screenrecord in android programatically

I trying to record the video using screenrecord utility in android lollipop using the following code.

Process p = Runtime.getRuntime().exec("screenrecord /sdcard/test.mp4",null,null);
Thread.sleep(60 * 1000);
p.destroy();

It creates the file in sdcard but nothing is recorded and file size is zero.

If I use the below command in adb shell screenrecord /sdcard/test.mp4. It is working fine.

Is anybody come across this scenario.

Note : I am using the below permission in the app.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Device is Non-Rooted device

Device is Non-Rooted device

Then you cannot run screenrecord . That is a development-time tool that is not usable by ordinary SDK apps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM