Hi, I've written a little program (see below) to record audio using MediaRecorder. While everything works fine in the emulator (SDK1r2), the program does not work on the real phone (HTC G1). On the phone, after pressing the start button, the audio file is created, but no content is written to it (i.e. the file size remains 0). Also, no exception is shown in logcat, and no AudioStreamInGeneric events are generated (such events are generated when running the program on the emulator).
Is there maybe a setting on the phone that I have to turn on (or off)? Or am I missing something else? I've set the permission to record audio in the android-manifest.xml file using <uses-permission android:name="android.permission.RECORD_AUDIO"></uses- permission> Thanks for any help! Michael ------------------------------ My program code: package ch.ethz.dcg.mictest; import android.app.Activity; import android.media.MediaRecorder; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; public class MicTest extends Activity { private final static String TAG = MicTest.class.getSimpleName(); private MediaRecorder recorder; private Button button; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); recorder = new MediaRecorder(); button = (Button)findViewById(R.id.button); button.setText("start"); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { buttonClicked(); } }); } private void buttonClicked() { if (button.getText().equals("start")) { try { recorder = new MediaRecorder(); String path = "/sdcard/test.3gpp"; recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(path); recorder.prepare(); recorder.start(); button.setText("stop"); } catch (Exception e) { Log.w(TAG, e); } } else { try { recorder.stop(); recorder.release(); // Now the object cannot be reused button.setEnabled(false); } catch (Exception e) { Log.w(TAG, e); } } } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---