问题描述
我有这个记录屏幕的功能。它适用于 Android 6 到 9。从 Andriod 10 开始,问题开始出现。
private void initRecorder() {
try {
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mediaRecorder.setoutputFormat(MediaRecorder.OutputFormat.MPEG_4);
//VIDEO RATES
mediaRecorder.setVideoEncodingBitRate(512 * 1000);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); //Be very careful with the Encoder,it should match the VideoSource
mediaRecorder.setVideoSize(disPLAY_WIDTH,disPLAY_HEIGHT);
mediaRecorder.setVideoFrameRate(30);
//AUdio RATES
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB);
mediaRecorder.setAudioEncodingBitRate(96000);
mediaRecorder.setAudioSamplingRate(44100);
videoUri = FilingSystem.Companion.getCompletedLectures()
+ "/" + fileName + "_dub_Records_" + new SimpleDateFormat("dd-MM-yyyy-hh-mm-ss")
.format(new Date()) +
".mp4";
compressedVideo = FilingSystem.Companion.getCompletedLectures()
+ "/" + fileName + "_Compressed_dub_Records_" + new SimpleDateFormat("dd-MM-yyyy-hh-mm-ss")
.format(new Date()) +
".mp4";
int rotation = getwindowManager().getDefaultdisplay().getRotation();
int orientation = ORIENTATION.get(rotation + 90);
mediaRecorder.setorientationHint(orientation);
mediaRecorder.prepare();
surface = mediaRecorder.getSurface();
} catch (IOException e) {
e.printstacktrace();
}
}
从函数中可以看出mediaRecorder已经准备好了。所以现在当我在 onActivityResult 中启动它时,因为我必须为此获得一些权限,它适用于 Android 6 到 Android 9。但在 Android 10 中,我收到错误
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null,request=1000,result=-1,data=Intent { (has extras) }} to activity {com.example.ynot/com.example.ynot.Activities.LectureStudio}: java.lang.IllegalStateException
at android.app.ActivityThread.deliverResults(ActivityThread.java:5589)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5630)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)