I've been trying this for over a day and haven't found anyone who
seems to know, so I'm hoping someone can help.
Every time I try to record, I get the following error:
java.lang.RuntimeException: start failed.
I've added the following to my manifest file:
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
My code is below:
ImageButton btnRec = (ImageButton) findViewById( R.id.btnRec );
if( btnRec != null ){
btnRec.setOnClickListener( new OnClickListener(){
public void onClick( View viewParam ) {
try{
/*Create an Intent that will start your Activity
*/
recorder.setAudioSource
(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat
(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder
(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile("TesterPath");
recorder.prepare();
recorder.start(); // Recording is now started
tvStatus.setText("Recording now");
} catch (IllegalStateException e) {
tvError.setText("IllegealState Error found: " + e);
} catch (Exception e) {
tvError.setText("Generic Error found: " + e);
}
}
});
}
ImageButton btnStop = (ImageButton) findViewById
( R.id.btnStop);
if( btnStop != null ){
btnStop.setOnClickListener( new OnClickListener(){
public void onClick( View viewParam ) {
try{
recorder.stop();
recorder.reset(); // You can reuse the object by
going back to setAudioSource() step
recorder.release(); // Now the object cannot be
reused
tvStatus.setText("Recording stopped");
} catch (IllegalStateException e) {
tvError.setText("IllegealState Error found: " + e);
} catch (Exception e) {
tvError.setText("Generic Error found: " + e);
}
}
});
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---