try {
String path = "/sdcard/recorder.amr";
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path+name);
recorder.prepare();
recorder.start();
try {
Runnable.wait(10000);
} catch (Exception exp) {
exp.printStackTrace();
}
recorder.stop();
recorder.release();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
10秒钟哦,等也得等,不等也得等,不用线程怎么行。

录像就是Audio+Video,所以还要加点东西,看代码:
path = "/sdcard/v.3gp";
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setVideoSize(176, 144);
recorder.setVideoFrameRate(15);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);

更多相关文章

  1. Android 为什么主线程的looper 一直循环不会ANR
  2. Android使用Sensor感应器实现线程中刷新UI创建android测力计的功
  3. Android引入广播机制的用意。单线程模型Message、Handler、Messa
  4. UWP与Android中如何在多线程中刷新UI
  5. android的线程封装
  6. Android 跨线程更新 UI
  7. android将线程绑定在指定CPU
  8. android的多线程操作(一)

随机推荐

  1. 企业级Android Application Activity管理
  2. android 使用vcard示例
  3. Android类型转换 积累
  4. android studio详细的编译错误提示
  5. Android检测版本更新(读取apk配置文件中的
  6. Android软键盘调用及隐藏,以及获得点击软
  7. Android Intent多种传值方式
  8. android标题栏去除和全屏
  9. android实现ftp上传、下载,支持文件夹
  10. Android Q 使用通知栏消息