title: Call method from another class on Android
body: <p>I have created two classes, actually both of them extends Activity. What I am trying to do is to call a method from the second class. </p>
  
  <p>What I am trying to do is calling the method from second class then implemented in first class, unfortunately I did not have success in that.</p>
  
  <p>I need your help to solve this problem. Thank you  </p>
  
  <p>My first class:</p>
  
  <pre><code>package com.math4kids;
  
  import android.app.Activity;
  import android.os.Bundle;
  
  public class testing002 extends Activity {
  
  private Sounds myotherclass;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.numeracy);
  
      myotherclass.Randomsoundforrightanswer();
  
  }
  
  }
  </code></pre>
  
  <p>The second class:</p>
  
  <pre><code>package com.math4kids;
  
  import java.util.Random;
  
  import android.app.Activity;
  import android.content.Context;
  import android.media.MediaPlayer;
  
  public class Sounds extends Activity {
  
  MediaPlayer cool, good, perfect, sweet, excellent, goodthinking, greatjob,
          notbad, thatstheway, youdidit, yes, again, wrong, sorry,
          sundfornum01, sundfornum02;
  public Random random = new Random();
  
  public Sounds(Context context){
      super.getApplicationContext();
  }
  
  public void Randomsoundforrightanswer() {
      cool = MediaPlayer.create(this, R.raw.cool);
      good = MediaPlayer.create(this, R.raw.good);
      perfect = MediaPlayer.create(this, R.raw.perfect);
      sweet = MediaPlayer.create(this, R.raw.sweet);
      excellent = MediaPlayer.create(this, R.raw.excellent);
      goodthinking = MediaPlayer.create(this, R.raw.goodthinking);
      greatjob = MediaPlayer.create(this, R.raw.greatjob);
      notbad = MediaPlayer.create(this, R.raw.notbad);
      thatstheway = MediaPlayer.create(this, R.raw.thatstheway);
      youdidit = MediaPlayer.create(this, R.raw.youdidit);
      yes = MediaPlayer.create(this, R.raw.yes);
  
      switch (random.nextInt(11)) {
  
      case 0:
          cool.start();
          break;
      case 1:
          good.start();
          break;
      case 2:
          perfect.start();
          break;
      case 3:
          sweet.start();
          break;
      case 4:
          excellent.start();
          break;
      case 5:
          goodthinking.start();
          break;
      case 6:
          greatjob.start();
          break;
      case 7:
          notbad.start();
          break;
      case 8:
          thatstheway.start();
          break;
      case 9:
          youdidit.start();
          break;
      case 10:
          yes.start();
          break;
  
      }
  
  }
  
  
  }
  </code></pre>