我试图创建一个类,设置和开始录音,但一旦我点击按钮的应用程序崩溃。我把问题隔离到了我为medirecorder设置参数的地方。
private void startRec() throws IOException {
if (mrecorder!=null)
mrecorder.release();
mrecorder= new MediaRecorder();
-> mrecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
/*
mrecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mrecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mrecorder.setOutputFile(MFILE);
mrecorder.prepare();
mrecorder.start();
*/
}
当注解开头上方带有箭头的行被执行时,它会崩溃。我还向清单添加了以下权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
非常感谢您的帮助。
更新的logcat
[05-12 00:39:13.299 30086:30158 d/]ro.exynos.dss已启用:0 05-12 00:39:13.309 30086-30158/record66.record6 d/mali_winsys:new_window_surface返回0x3000,[1440x2560]-format:1 05-12 00:39:13.319 30086-30086/record66.record6 w/displaylistcanvas:displaylistcanvas在未绑定的rendernode(没有mowningview)05-12 00:39:13.319 30086-30158/record66.record6 d/libglesv1:dts\u glapi:dts不允许用于包:record66.record6 05-12 00:39:13.359 30086-30086/record66.record6d/viewrootimpl:msg\u resized\u report:ci=rect(0,96-0,0)vi=rect(0,96-0,0)或=1 05-12 00:39:13.389 30086-30086/record66.record6 i/timeline:timeline:activity\u idle id:android.os。binderproxy@682466c time:234401322 05-12 00:39:15.749 30086-30086/record66.record6 d/viewrootimpl:viewpostimeinputstage进程指针0 05-12 00:39:15.879 30086-30086/record66.record6 d/viewrootimpl:viewpostimeinputstage进程指针105-12 00:39:15.929 30086-30086/record66.record6 d/androidruntime:关闭vm 05-12 00:39:15.939 30086-30086/record66.record6 e/androidruntime:致命异常:主进程:record66.record6,pid:30086 java.lang.runtimeexception:setaudiosource失败。位于android.media.mediarecorder.\u setaudiosource(本机方法)位于android.media.mediarecorder.setaudiosource(mediarecorder)。java:488)在record66.record6.mainactivity.startrec(mainactivity。java:58)在record66.record6.mainactivity.onclick(mainactivity。java:94)在android.view.view.performclick(view。java:5697)在android.widget.textview.performclick(textview。java:10815)在android.view.view$performclick.run(view。java:22526)在android.os.handler.handlecallback(handler。java:739)在android.os.handler.dispatchmessage(handler。java:95)在android.os.looper.loop(looper。java:158)在android.app.activitythread.main(activitythread。java:7229)在java.lang.reflect.method.invoke(本机方法)位于com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit)。java:1230)在com.android.internal.os.zygoteinit.main(zygoteinit。java:1120)05-12 00:39:17.909 30086-30086/record66.record6 i/进程:发送信号。pid:30086信号:9
1条答案
按热度按时间gopyfrb31#
请看看logcat是什么。
告诉我们你犯了什么错误。所以我可以帮忙。