title: How to use new class wiith media player in main activity?
body: <p>I'm trying to create new class, becouse I will have there many of sound file, but I don't know how to use it in main ativity. Here is my example code of sound.java:</p>
  
  <pre><code>package app.damian.komunikat_v1;
  import android.media.MediaPlayer;
  import android.support.v7.app.AppCompatActivity;
  
  public class sound extends MainActivity{
  
  final MediaPlayer sound1 = MediaPlayer.create(this,R.raw.miau);
  final MediaPlayer sound2 = MediaPlayer.create(this,R.raw.lol);
  
  }
  </code></pre>
  
  <p>And now i'm trying to use sound1.start(); in main activity, but i don't know how. Any suggestions?</p>
  
  <p>EDIT:
  This is my MainActivity.java:
        this is my MainActivity.java: </p>
  
  <pre><code>   package app.damian.komunikat_v1;
  
    import android.media.MediaPlayer;
    import android.support.v7.app.AppCompatActivity;
   import android.os.Bundle;
   import android.view.View;
   import android.widget.Button;
  
   public class MainActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Button guzik = findViewById(R.id.button);
      final MediaPlayer sound1 = MediaPlayer.create(this,R.raw.miau);
  
      guzik.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              sound1.start();
  
          };
      });
    }
   }
  </code></pre>