1. Are you ready for the Galaxy S20? Here is everything we know so far!

AudioRecord crashing app

Discussion in 'Android Apps & Games' started by mcindafizzy, May 16, 2011.

  1. mcindafizzy

    mcindafizzy Lurker
    Thread Starter

    Greetings,

    I am just getting started with Android and I'm trying to instantiate an instance of AudioRecord - unfortunately, the app crashes upon instantiation while running in the emulator. Is this a known problem? Or is there a common mistake that developers make with regard to AudioRecord?

    Code (Text):
    1.  
    2. private AudioRecord audioIn;
    3.    
    4.     /** Called when the activity is first created. */
    5.     @Override
    6.     public void onCreate(Bundle savedInstanceState) {
    7.         super.onCreate(savedInstanceState);
    8.         setContentView(R.layout.main);
    9.        
    10.         if(audioIn == null)
    11.         {
    12.             int bufferSize = AudioRecord.getMinBufferSize(44100, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT);
    13.             audioIn = new AudioRecord(MediaRecorder.AudioSource.MIC,
    14.                                       44100,
    15.                                       AudioFormat.CHANNEL_IN_MONO,
    16.                                       AudioFormat.ENCODING_PCM_16BIT,
    17.                                       bufferSize);
    18.             System.out.println("Initialized AudioRecord.");
    19.         }
    20.     }
    21.  
    Error:
    The application Test Audio Input (process com.spawn) has stopped unexpectedly. Please try again.

    Thanks.

    Matt
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...