title: Play background music in all activities of Android app
body: <p>I spend about 20 hours until now and my problem there still is .
  I am creating an android application that has several Activities (mainMenu , aboutUs,setting).
  I followed the best answered of below link and that was O.K . 
  <a href="https://stackoverflow.com/questions/22541751/music-played-using-asynctask-isnt-stopping-by-using-cancel">Music played using asyncTask isn't stopping by using cancel</a></p>
  
  <p>When i run my app,(my code is in mainActivity ), the music begin and it does not stop when navigate to other Activities . This is GOOD .
  But i put a <strong>ToggleButton</strong> in my setting_activity Activity that i hope this Button starts and stops this music. NOW my question is how can i stop and/or start music again from setting_activity ?</p>
  
  <p>in another solution :
  I create a class MusicManager and i call it`s start and stop . 
  But this was several problems too :</p>
  
  <ol>
  <li>Music started in mainMenu_activity but only play for about 15 seconds and then stopped.</li>
  <li><p>I could not stop the music from another activities.At this time i play music in mainMenua_ctivity as this line codes :</p>
  
  <pre><code>MusicManager mm = new MusicManager(this, R.raw.background_sound);
  mm.play();
  </code></pre></li>
  </ol>
  
  <p>How can i stop playing that ?
   3. The music stopped when i navigate to other activities .</p>
  
  <pre><code>public class MusicManager implements OnPreparedListener {
  
      static MediaPlayer mPlayer;
      Context context;
      private int mySoundId;
  
      public MusicManager(Context ctx, int musicID) {
          context = ctx;
          mySoundId = musicID;
          mPlayer = MediaPlayer.create(context, mySoundId);
          mPlayer.setOnPreparedListener(this);
      }
  
      public void play() {
          mPlayer = MediaPlayer.create(context, mySoundId);
  
      }
  
      public void stop() {
          mPlayer.stop();
          mPlayer.release();
      }
  
      @Override
      public void onPrepared(MediaPlayer player) {
          player.start();
          mPlayer.setLooping(true);
          mPlayer.setVolume(25, 25);
  
      }
  
  }
  </code></pre>
  
  <p>Finally i want to play a background music in all activities without stop/start music .
  How can i do it ?</p>