1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| private MediaRecorder mMediaRecorder; private void startRecord(){ if (mMediaRecorder == null){ mMediaRecorder = new MediaRecorder(); mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB); mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); File file = new File(Environment.getExternalStorageDirectory().getPath(), "hello.log"); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } mMediaRecorder.setOutputFile(file.getAbsolutePath()); mMediaRecorder.setMaxDuration(1000 * 60 * 10); try { mMediaRecorder.prepare(); } catch (IOException e) { e.printStackTrace(); } mMediaRecorder.start(); } handler.postDelayed(runnable, 200); }
|