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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:30:55+00:00 2026-06-09T20:30:55+00:00

In a child activity, I record some audio using MediaRecorder and have two buttons:

  • 0

In a child activity, I record some audio using MediaRecorder and have two buttons: The first one will start recording and second one is going back to its parent activity. However every time I hit go back button, it takes a long time to return to main activity’s view. My code inside go back button’s callback is:

public void onClick(View arg0) {        
        if (arg0.getId() == R.id.startRecord) 
        {
           StartRecording();
        } 

        else if (arg0.getId() == R.id.goBack) 
       {
       if(mediaRecorder!=null)
           {
             mediaRecorder.stop();
             mediaRecorder.release();
             mediaRecorder = null;
           }
       this.finish();

       }
   }

The parent activity’s onCreate() method only initiate several buttons and set listener methods to them. I really cannot figure out why go back action will take a long time. A phenomenon worthy to mention is that if I don’t record first but hit go back button first, it goes back really quick to the parent activity. The long responding time only happens after I record some audio. I do upload the recorded audio however I put the uploading in a AsyncTask task and I can get feedback when uploading work is done. After I see the feedback, and even wait for some time, the go back button still takes a long time to bring me back to main activity. Anyone has advices on this? Thanks!

  • 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-09T20:30:56+00:00Added an answer on June 9, 2026 at 8:30 pm

    You could override the back button, albeit from what I have seen it seems a lot of developers aren’t to friendly to the idea.

    @Override
    public void onBackPressed() {
       mediaRecorder.stop();
       mediaRecorder.release();
       mediaRecorder.reset();
       mediaRecorder = null;
    }
    

    See if that works for you.


    Better yet, something like this could be more useful, that way you could easily call the stop() method throughout with ease:

    public void onClick(View arg0) {        
        if (arg0.getId() == R.id.startRecord) {
            StartRecording();
        } else if (arg0.getId() == R.id.goBack) {
            if(mediaRecorder!=null) {
            stopRecording();
        }
        this.finish();
    }
    
    
    public void stopRecording() throws IOException {
        mediaRecorder.stop();
        mediaRecorder.release();
        mediaRecorder.reset();
        mediaRecorder = null;
    }
    
    @Override
    public void onBackPressed() {
       stopRecording();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How I can get name of parent activity in child activity. I have two
I have a main activity which calls a child one via Intent I =
I have one problem using ActivityGroup . I have two activities inside an ActivityGroup
I have a main activity that launches a child activity using the following code:
I have an android application that launches a child Activity under certain situations. Both
I have a LinearLayout and its child - ImageView. My activity's onCreate does nothing
I have a webview that I'm creating in an Activity which is a child
I have 2 activities. In child activity i have put something like that in
i am using following code to start my activity public void onClick(View v) {
My application is Tab using ActivityGroup.I have done title of each activity using getParent().getParent().setTitle(New

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.