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 8909511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:26:53+00:00 2026-06-15T03:26:53+00:00

I don’t kno why but the start() method throw an error and crash the

  • 0

I don’t kno why but the start() method throw an error and crash the app:

public class Noise extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.noise);
    MediaRecorder recorder=new MediaRecorder();
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    try{
        recorder.prepare();
    }catch(IllegalStateException e){
        Log.d("Error",e.toString());
        e.printStackTrace();
    }catch(IOException e){
        Log.d("Error",e.toString());
        e.printStackTrace();
    }
    recorder.start();
    Timer timer=new Timer();
    timer.scheduleAtFixedRate(new RecorderTask(recorder), 0, 500);
}
private class RecorderTask extends TimerTask{
    TextView risultato=(TextView) findViewById(R.id.risultato_recorder);
    private MediaRecorder recorder;
    public RecorderTask(MediaRecorder recorder){
        this.recorder = recorder;
    }
    public void run(){
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                risultato.setText("" + recorder.getMaxAmplitude());
            }
        });
    }
}
}

if i remove the prepare and the start, it work but return always 0 in the textview.
anyone can help me? this thing make me crazy

this is the logcat: https://dl.dropbox.com/u/16047047/log.txt

and in the phone, it crash.

  • 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-06-15T03:26:54+00:00Added an answer on June 15, 2026 at 3:26 am

    It seems you miss a recorder.setOutputFile(PATH_NAME); See the documentation for MediaRecorder

    At least, this is what the stack trace tells us:

    11-29 16:04:08.933: W/System.err(9323): java.io.IOException: No valid output file
    

    This is the relevant source code for MediaRecorder.prepare():

    public void prepare() throws IllegalStateException, IOException
    {
        if (mPath != null) {
            FileOutputStream fos = new FileOutputStream(mPath);
            try {
                _setOutputFile(fos.getFD(), 0, 0);
            } finally {
                fos.close();
            }
        } else if (mFd != null) {
            _setOutputFile(mFd, 0, 0);
        } else {
            throw new IOException("No valid output file");
        }
        _prepare();
    }
    

    (you can read it on grepcode) The exception is thrown if both the File object and the FileDescriptor are null. So I don’t think you can use MediaRecorder without supplying a file. You can try the tricky /dev/null but I don’t know if it works, and can’t test right now

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

Sidebar

Related Questions

Don't ask why, but is there any way to suppress a failed linking error?
Don't ask me why but i can't use this method because I need to
don't know better title for this, but here's my code. I have class user
don't know if the title describes anything about what I'm trying to say but
Don't ask me how but I'm in a situation where I have DCPs published
Don't really know how to formulate the title, but it should be pretty obvious
Don't know how to google for such, but is there a way to query
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
Don't ask me why but I need to do the following: string ClassName =
I don't know why, but this code worked for me a month ago... maybe

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.