How to stop the music when game is received to the background ?

edited February 2017 in Android Mode

How to stop the music when game is received to the background ?

Tagged:

Answers

  • @hamza===

    as for that you can use the onPause() && onStop() mehods.

  • Can you give me an example code ?

  • Answer ✓

    depends of the sound is it from mediaplayer? is it from audio service? is it from audio track?

    yet principle is the same let us say you are using some instance from MediaPlayer, mp:

            public void onPause{
            super.onPause();
            if(mp!=null){
    
            mp.stop();
            mp.release();
            mp=null;
    
            }
    
            }
    

    same code for onStop();

  • Thank you akenaton :)

Sign In or Register to comment.