title: How to access instance variable and method in main activity from other activity?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/708012/android-how-to-declare-global-variables">Android: How to declare global variables?</a>  </p>
  </blockquote>
  
  
  
  <p>I want to access public instance variable in main activity from other activity.
  And I want to call public method in main activity.
  How can I do that?</p>
  
  <pre><code>class MainActivity extends Activity {
      public int i;
      public void myMethod() {}
  }
  
  class MyActivity extends Activity {
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          // How can I access variable i in MainActivity?
          // And How can I call myMethod() in MainActivity?
      }
  }
  </code></pre>