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

  • Home
  • SEARCH
  • 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 3679388
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:27:12+00:00 2026-05-19T03:27:12+00:00

I am having a couple of problems recording sound on a device. The code

  • 0

I am having a couple of problems recording sound on a device. The code I am using if from the android dev site (Site Link) and is as follows:

    public void onClickStart(View v) throws IllegalStateException, IOException{
        startRecord();
    }

    public void onClickStop(View v) throws IllegalStateException, IOException{
        stopRecord();
    }

    private void startRecord() throws IllegalStateException, IOException{
        recorder = new MediaRecorder(); 
        recorder.setAudioSource(MediaRecorder.AudioSource.MIC);  //ok so I say audio source is the microphone, is it windows/linux microphone on the emulator? 
        recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); 
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 
        recorder.setOutputFile("/sdcard/test.3gpp"); 
        recorder.prepare(); 
        recorder.start();  
    }

    private void stopRecord(){
        recorder.stop();
//      recorder.release();
    }

With 2 buttons in the main layout which it turn both stop and start the recording (in theory that is).

But from LogCat when trying this out on my device (really cant be bothered with trying on the emulator) I get the following errors:

Error 1:
ERROR/MediaRecorder(14541): start called in an invalid state: 4
java.lang.IllegalStateException: Could not execute method of the activity
Caused by: java.lang.reflect.InvocationTargetException

Error 2:
Caused by: java.io.FileNotFoundException: /sdcard/test.3gpp (Permission denied)

And I also have the following permissions set in my Manifest.xml file:

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  • 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-19T03:27:12+00:00Added an answer on May 19, 2026 at 3:27 am

    Silly Error here sorry, it didn’t work because I had the phone mounted on my laptop so it couldn’t actually reach the sdcard.

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

Sidebar

Related Questions

I am having a couple problems with the code from the tutorial: ListView Tutorial
I'm having a couple of problems with this site. Actually it's my lack of
I'm having a couple of problems with circular reference/dependency that I've been sitting on
I am trying to learn PHP5 and am having a couple of problems with
I'm having a couple of problems with an alarm app I am developing. The
I am having a couple of issues deciding how best to describe a certain
I've been profiling an application all day long and, having optimized a couple bits
Having a problem getting a TreeView control to display node images. The code below
I'm migrating a couple of projects from an ant build to a maven one.
I have two problems with the below code that I need help fixing: 1)

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.