outputfile= Environment.getExternalStorageDirectory().getAbsolutePath()+"/recording.3gp";;
audiorecorder = new MediaRecorder();
audiorecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
audiorecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
audiorecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
audiorecorder.setOutputFile(outputfile);
record.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try{
audiorecorder.prepare();
audiorecorder.start();
}
catch (IllegalStateException e)
{
e.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
record.setEnabled(true);
stop.setEnabled(true);
Toast.makeText(getApplicationContext(), "Recording started", Toast.LENGTH_SHORT);
}
});
stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
audiorecorder.stop();
audiorecorder.release();
audiorecorder =null;
stop.setEnabled(false);
play.setEnabled(true);
Toast.makeText(getApplicationContext(), "Record successfully recorded", Toast.LENGTH_SHORT);
}
});
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MediaPlayer m = new MediaPlayer();
try{
m.setDataSource(outputfile);
}
catch ( IOException e)
{
e.printStackTrace();
}
try{
m.prepare();
}
catch(IOException e)
{
e.printStackTrace();
}
m.start();
Toast.makeText(getApplicationContext(), "Playing audio", Toast.LENGTH_SHORT);
}
});
这是我创建的记录。我创建了另一个包含listview的意图,我希望在其中显示SAVED记录。 任何想法如何保存记录?然后如何在列表视图中显示它们?