title: MainActivity context Android
body: <p>I need to fetch the MainActivity context and call getIntent() to process the intent that started the Activity.</p>
  <p>Due to some reasons, I don't want to do this in my MainActivity (that would have been a simple getIntent() in any non-static method of the class).</p>
  <p>The MainActivity's instance will be exposed (somehow) and with that object, I need to invoke getIntent().</p>
  <p>There's the following way:</p>
  <pre><code>public class MainActivity extends Activity {
    
    // Store the activity context
    private static Activity activityContext;
  
    public void onCreate() {
      activityContext = this;
    } 
  
    public static Activity getActivityContext () {
      return activityContext;
    }
  }
  </code></pre>
  <p>But is there any other way to get the MainActivity context? Like a direct func to the Activity's instance instead of capturing the instance and exposing a method as shown above..</p>