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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:51:26+00:00 2026-06-14T13:51:26+00:00

I am new to Android programming and i have a problem that i can

  • 0

I am new to Android programming and i have a problem that i can not solve without your help…Please, give me a hand… 😉

When i start playing my audio file, i can not stop it. Instead, I am quitting the application.

I play audio file with this code:

public class Word1Audio extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.word1video);



        MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.lige);
      mediaPlayer.start();



    }

}

HOWEVER, when i try to stop it when the back button is pressed by this piece of code

@Override
public void onBackPressed() {
// do something on back.
return;
}

my applications closes down and audio continues to play…

Do you have an idea why the application closes down? And how can i just stop the music and go back to the previous page…??

Thank you for your time and help… 🙂

  • 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-14T13:51:27+00:00Added an answer on June 14, 2026 at 1:51 pm

    you could try

     MediaPlayer mediaPlayer;
    
     @Override
     public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.word1video);
        mediaPlayer = MediaPlayer.create(this, R.raw.lige);
        mediaPlayer.start();
     }
    
     @Override
     public void onBackPressed() {
        if( mediaPlayer.isPlaying() ) {
          mediaPlayer.stop();
        }
        super.onBackPressed();
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm programming for Android 2.1.Could you help me with the following problem? I have
I'm quite new to android programming and I have the following problem. I want
I'm new in Android programming so I am asking for your help in my
I am new to Android programming and face a challenge that probably can be
im new in android programming.. i have a problem here. i wanna make an
So I am fairly new to android programming. I have a database and I
I'm new to Android & Java programming but have been programming in .NET for
I am new to Android and Java programming. I have a class which implements
I'm new to android programming and i have a question I'm developing an alarm
I have a project that is just using Android 1.5 for programming, but with

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.