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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:34:47+00:00 2026-06-04T09:34:47+00:00

I would like to find a solution on how to stop the music when

  • 0

I would like to find a solution on how to stop the music when user go back to the Main Activity.

My code is below, user can go back to the Activity A as usually but the music still play from Activity B.

I have the second Activity as the code below:

Layout A

<Button
    android:id="@+id/buttonUrl"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="My Song" />

Java of Activity A

public class MySongActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        final Context context = this;

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

         final Button button = (Button) findViewById(R.id.buttonUrl);
         button.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {

                Intent intent = new Intent(context, WebViewActivity.class);

                startActivity(intent);
         }
     });
}
}

Layout B

<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none" />

Java of Activity B

public class WebViewActivity extends Activity {

WebView mWebView;
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.playlist);

    mWebView = (WebView) findViewById(R.id.webView1);
    mWebView.setWebViewClient(new HelloWebViewClient());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setPluginsEnabled(true);
    mWebView.getSettings().setAllowFileAccess(true);
    mWebView.loadUrl("http://m.orkun2u.com/msopheap/song/mysongs.htm");
}
private class HelloWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
        mWebView.goBack();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
}

Kindly please help me. I do appreciate for your help.

Note:

I tried all the way that Google it but still doesn’t stop the music.

  • 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-04T09:34:49+00:00Added an answer on June 4, 2026 at 9:34 am

    just one more thing about what Padma Kumar said. the way to stop is to use the dismiss function.

    @Override
    public void onPause() {
        mWebView.setVisibility(View.GONE);
        mWebView.destroy();
        super.onPause();
    }
    

    updated: chenged the function from dismiss() to destroy(), for more: read here: http://developer.android.com/reference/android/webkit/WebView.html

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

Sidebar

Related Questions

I just stuck at this and cannot find solution. I would like to try
I would like to find a way to use custom User provider within a
I would like to find all comment blocks(/*...*/) but the function g_regex_match_full always returns
I think this shouldn't be a big problem, but I can't find the solution
I am new to android networking and would like to find the best solution/source
I would like to numerically find the solution to u_t - u_xx - u_yy
I would like to find a better solution to achieve the following three steps:
I would like to find a way to see what happens while my XAML
I would like to find the values of some of windows API constants, such
I would like to find a way to compile and package our iPhone application

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.