title: 2 Buttons with sound on click
body: <p>Here is the code from main activity</p>
  
  <p>I use Android Studio:</p>
  
  <p>import...</p>
  
  <pre><code>public class MainActivity extends Activity {
  public MediaPlayer mp;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      final Button lol2 = (Button) findViewById(R.id.lol2);
      lol2.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
              mp = MediaPlayer.create(getBaseContext(), R.raw.lol2);
              mp.start();
          }
      });
      final Button app2 = (Button) findViewById(R.id.app2);
      app2.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
              mp = MediaPlayer.create(getBaseContext(),R.raw.app2);
              mp.start();
          }
     });
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  }
  </code></pre>
  
  <p>Button in .XML</p>
  
  <pre><code>&lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Test"
      android:id="@+id/lol2"
  </code></pre>
  
  <p>Both buttons play the sounds... But when I click too often I get an error and it does not work anymore... why?</p>
  
  <h2>Edit:</h2>
  
  <p>When i click 10 times on a button it works... but if i click more and more on the button(s) they do not play the sound anymore. :-(</p>
  
  <p>The App works after many clicks on the buttons but there is no sound anymore.</p>
  
  <p>"mp.isPlaying();" if false then... ? i do not understand this.</p>