Audio Capture

The Toast displays the name of the audio file created and played by the app. We can call the setDataSource method of a MediaPlayer only once; subsequent calls do nothing. We therefore create a new MediaPlayer before each call to setDataSource. See Audio Capture.

To do: the RelativeLayout can be a LinearLayout with android:gravity="center".

Source code in Capture.zip

  1. CaptureActivity.java
  2. main.xml creates two ToggleButtons, record and play.
  3. AndroidManifest.xml contains
    1. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    2. <uses-permission android:name="android.permission.RECORD_AUDIO"/>

Things to try

  1. Examine the sound file. Type the following command in the Mac Terminal or Windows Command Prompt window.
    cd Desktop
    adb shell ls -l /mnt/sdcard/capture.3gp
    ----rwxr-x system   sdcard_rw     5912 2011-06-28 21:01 capture.3gp
    
    adb pull /mnt/sdcard/capture.3gp
    58 KB/s (5912 bytes in 0.098s)
    
    dir capture.3gp
    06/28/2011  09:01 PM           5,912 capture.3gp