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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:40:51+00:00 2026-06-11T10:40:51+00:00

I was just testing mediaplayer in android, i started a stream in the onCreate

  • 0

I was just testing mediaplayer in android, i started a stream in the onCreate method and I have a button that calls the finish() method. After clicking the button I can still hear the stream playing even though the activity is close, I am wondering if this is a leak of sorts and i will have to stop the player first before calling the finish() method, or if finish() method actually does not full kill the app to free up resources. Thank you for reading

            public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            Button add_function,exit_btn;   
            add_function = (Button) findViewById(R.id.view_chat);
            exit_btn = (Button) findViewById(R.id.exit_btn);


            MediaPlayer mp = new MediaPlayer();
            String URL_OF_FILE = "http://stream.radiosai.net:8002/";
    try {
        mp.setDataSource(URL_OF_FILE);
         mp.prepare();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

            mp.start();



        exit_btn.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                finish();
            }
        });
             }// EOF ONCREATE
  • 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-11T10:40:53+00:00Added an answer on June 11, 2026 at 10:40 am

    Calling finish() does not kill the application, it just destroys the current Activity that you’re finishing. Although I would think finishing the Activity would stop the MediaPlayer, what you should probably do in this case is override onDestroy(), and release your MediaPlayer object there. For instance:

    @Override
    public void onDestroy() {
        if(mediaPlayer != null) mediaPlayer.release();
        super.onDestroy();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just testing out the onLocationChanged method in Android , I have implemented
Ok, so i have a test page right now that is just testing my
I am using jScrollPane and are just testing it in all browsers and have
I've just started testing the water with WPF and I'm trying to bind the
This is a MVC 3 project. Just for testing, I have public class MyRoleProvider
I'm just testing out some basic networking code written in Visual C++. I have
I'm having problems making Capybara work with Rails. Just testing that suposedly interesting test
I am just testing a small program that I want to test. I am
I only have a vague hint of spec so far, but I'm just testing
This is driving me crazy. Just testing a site on IE9 and discovered that

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.