title: how to play different audio on button click android java
body: <p>I want to play music when a button is clicked, but I want to play different music with different button then the first music stopped and the second music would play.</p>
  
  <p><strong>code:</strong></p>
  
  <pre><code>charge = MediaPlayer.create(this, R.raw.charge);
  santai1 = MediaPlayer.create(this, R.raw.santai1);
  
  
  
  
  }
  
  public void charge(View view) {
      charge.start();
  
  
  }
  
  public void santai1(View view) {
      santai1.start();
  
  }
  </code></pre>
  
  <p>Say, I clicked charge button and then played the charge.mp3. Then I want to play santai1.mp3 but when I clicked the santai1 button the charge.mp3 will stop playing and the santai1.mp3 will play.</p>
  
  <p>I want this to be able the opposite and it can be done continuously.</p>
  
  <p>When I clicked santai1 button then santai1.mp3 will be played, while the santai.mp3 still playing I clicked the charge button. I want the santai1.mp3 stopped and then play the chage.mp3.</p>
  
  <p>When I clicked on charge button, then I clicked on santai1 button, both music started together.</p>