Android解决异常: startRecording() called on an uninitialized AudioRecord.
来源:互联网 发布:压缩至淘宝推荐画质 编辑:程序博客网 时间:2024/05/16 12:19
今天使用AudioRecord进行录音操作时候,报了下面的异常。
E/AndroidRuntime(22775): Java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.
解决办法:
1.看权限是否添加;
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
我的权限添加了还是报错。网上查找资料发现:出现上面问题的原因是录音的硬件资源被申请了,但是没有释放,然后你再次申请资源,导致初始化失败。这里需要注意的是不仅仅需要调用Release()方法。还需要把AudioRecord对象置为null,否则还是释放失败。下面是Android 开发网上面的一个对于AudioRecord的释放说明。
Releases the native AudioRecord resources. The object can no longer be used and the reference should be set to null after a call to release()。
所以要加个判断:
if(record == null){ record = new AudioRecord(MediaRecorder.AudioSource.MIC, mSampleRate, mChannelConfig, mAudioEncoding, mBufferSize * 5); }
0 0
- Android解决异常: startRecording() called on an uninitialized AudioRecord.
- [置顶] 我的Android进阶之旅------>Android解决异常: startRecording() called on an uninitialized AudioRecord.
- java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.
- BUG篇 Android AudioRecord 调用startRecording发生错误
- Android异常解决--A WebView method was called on thread 'JavaBridge'. All WebView methods must be called
- AudioRecord uninitialized Error
- java.lang.IllegalStateException: play() called on uninitialized AudioTrack.
- 解决 android audiorecord 蓝牙耳机 重启导致录音数据异常问题
- 处理Android SQLite - close() was never explicitly called on database异常
- called detach on an already detached child ViewHolder
- 解决android sqlite 中"close() was never explicitly called on database" 与java线程同步
- android audiorecord
- AudioRecord录音初始化异常
- close() was never explicitly called on databaseandroid.database.sqlite异常
- 处理AndroidSQLite-close()was never explicitly called on database异常
- "SetDestination" can only be called on an active agent that has been placed on a NavMesh.
- uninitialized constant Rake::DSL解决
- [Android]"commit already called"错误解决
- Java基础知识
- 在Visual Studio下配置OpenCV的3种方式
- 使用Httpclient向百度翻译提交POST请求 接受返回的JSON字符串 实现翻译功能(3)----BufferedReader与BufferedWriter的使用
- GCD定时器替换NSTimer不准的问题
- PHP搭建自己的MVC框架7 模型层
- Android解决异常: startRecording() called on an uninitialized AudioRecord.
- android studio 安装Intel HAXM为Android 模拟器加速
- leetcode-91. Decode Ways
- 名企笔试:2015携程Java工程师笔试题
- 教你如何在VR企业找到工作
- MathType编辑大三角形符号的方法
- JS编程
- 加密和签名的的作用
- 认识MVC框架