Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3853114
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:25:11+00:00 2026-05-19T17:25:11+00:00

Setting up a MediaRecorder as a simple Audio recorder, my recorderName.prepare() is being showing

  • 0

Setting up a MediaRecorder as a simple Audio recorder, my “recorderName.prepare()” is being showing by Eclipse as an “Unhandled IOException”.

If I put in place some error exception the program runs but obviously the .prepare statement doesn’t work.

As far as I can make out I have declared everything for the MediaRecorder:

AudioSource
OutPutFormat
Encoder
OutputFile

I have also declared RECORD_AUDIO and WRITE_EXTERNAL_STORAGE permissions in the manifest.

import android.media.MediaRecorder;
private MediaRecorder mRec;  //Gobal
.
.
.
public void StartRec() 
{
            mRec = new MediaRecorder();
            mRec.setAudioSource(MediaRecorder.AudioSource.MIC);
            mRec.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
            mRec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
            mRec.setOutputFile(Environment.getExternalStorageDirectory().getAbsolutePath()+"/test.3gp");

            mRec.prepare(); //Underlined as an Unhandled Exception 
            mRec.start();
}

Eclipse recommends surrounding it a try and catch or adding a declaration to the method.

As for a stack trace, which is produced from the emulator?, I cannot compile the application.

Also please bear in mind I have been at this for less than two weeks.

This question may be acheingly easy, but considering I have been only just started out on Android I feel justified in opting out and asking for help 🙁

Thank You

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:25:11+00:00Added an answer on May 19, 2026 at 5:25 pm

    that prepare() function can throw an IOException, and therefore Java dictates that you should always make sure that exception is ‘caught’, or thrown.

    Eclipse is warning you that you are not catching this, and the quickest way is to do as Eclipse is suggesting

    try{
        mRec.prepare(); //Underlined as an Unhandled Exception 
    }catch (IOException e){
        Log.e("yourTag","There was a problem: ".e->toString());
    }
    

    This only means that if there is an error, you catch it and do error reporting.
    Now you say this:

    *If I put in place some error exception the program runs but obviously the .prepare statement doesn’t work. *

    But is that really that obvious? If you are generating an error, you should try and fix that, but if you are not (like you seem to imply?) then the code will just work. Try-catch doesn’t prevent the prepare from running, it only gives you an option for the case (this should be an exceptional case, like for instance the file could not be used, found or opened) that there is a problem.

    (also, check out this link: oracle java manual for some more info on exceptions )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question has also been asked at Problems with MediaRecorder class setting audio source
can anybody provide me code for recording audio using MediaRecorder of android by setting
Setting up email details in web.config - but no email is being sent! <appSettings>
Setting terminal title is easy with echo -e \e]0;some title\007 . Works with pretty
I'm recording videos with MediaRecorder, but it appears that whatever setting I use, the
Setting up a simple grails app with Dojo, i used the grails install-plugin dojo
Im setting up a simple checker program thing. For now, its extremely simple and
Setting up Eclipse on each machine I work it a real headache and I
Setting up new git installations. On one Windows laptop, I'm running (under cygwin): git
Setting onchange event for CheckBoxList using the following code doesn't work. chkListUserGroup.Attributes.Add(onchange, document.forms[0].isRecordModified.value='true';); How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.