[°³¹ß Tip] Æù ¸¶ÀÌÅ©¿¡ ³ìÀ½Çϱâ |
|
|
![](icon/private_name/1.gif) |
8³â Àü |
Button startBtn = (Button) findViewById(R.id.start);
startBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String path = Environment.getExternalStorageDirectory()
.getAbsoluteFile() + "/tmp/abc.amr";
String state = android.os.Environment.getExternalStorageState();
if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
return;
}
// make sure the directory we plan to store the recording in
// exists
File directory = new File(path).getParentFile();
if (!directory.exists() && !directory.mkdirs()) {
return;
}
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);
try {
recorder.prepare();
} catch (Exception ex) {
ex.printStackTrace();
}
recorder.start();
}
|
|
̵̧ : 272 |
̵̧
¸ñ·Ï
|
|