How to call instance method in predefined class from another class in android
<p>I have two classes, shown below:</p>

<p>TestActivity.java</p>

<pre><code>public class TextActivity extends Activity {
  public void onCreate(Bundle savedinsstate) {
    super.onCreate(savedinsstate);
    Intent intent=new Intent(this,MYMapActivity.class);
    startActivity(intent);
    MYMapActivity.ma.displayGoogleMaps();
  }
}
</code></pre>

<p>MYMapActivity.java</p>

<pre><code>public class MYMapActivity extends MapActivity {
  public static MYMapActivity ma;

  public void onCreate(Bundle savedinsstate) {
    super.onCreate(savedinsstate);
    ma=this;
  }

  public void displayGoogleMaps(){
    //some code here.
  }
}
</code></pre>

<p>From the above when I'm calling MYMapActivity.ma.displayGoogleMaps() I'mm getting NullPointerException. I have debugged the code then finally I found that in place of ma I am getting null. How can I resolve this?</p>
