简体   繁体   English

无法以编程方式在Android中使用ScreenRecord录制视频

[英]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. 我尝试使用以下代码在android棒棒糖中使用screenrecord实用工具录制视频。

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. 它在sdcard中创建文件,但不记录任何内容,文件大小为零。

If I use the below command in adb shell screenrecord /sdcard/test.mp4. 如果我在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 . 这样就无法运行screenrecord That is a development-time tool that is not usable by ordinary SDK apps. 那是一个开发时工具,普通的SDK应用程序无法使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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