title: Create static reference to Context, Use it everywhere and finally let Garbage Collected
body: <p>I have a little problem about needing <strong>Activity/Application</strong> everywhere... <br />
  More precisely I have classes defined like this:</p>
  
  <pre><code>public class MyApp extends Application {
  
       private static Activity currentActivity;
       private static MyApp instance;
  
       @Override
       public void onCreate() {
           super.onCreate();
           instance = this;
       }
  
       public static void setCurrentActivity(Activity activity) {
           currentActivity = activity;
       }
  }
  </code></pre>
  
  <p>And I have an Extended activity like this:</p>
  
  <pre><code>public class MyActivity extends Activity {
  
         ....
  
         @Override
         public void onResume() {
            super.onResume();
            MyApp.setCurrentActivity(this);
         }
  
  
         ....
  
         @Override
         public void onDestroy() {
            super.onDestroy();   
            MyApp.setCurrentActivity(null);  // for nullifying static reference
  
         }
   }
  </code></pre>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Is the above code snippet fair ?</li>
  <li>Should I use <code>super.onDestroy();</code> after the <code>MyApp.setCurrentActivity(null);</code> to verify that activity is not reffered and destroyed succesfully?</li>
  <li>And most important, what about <strong>static</strong> reference <em>instance</em>? where can I nullify it to not prevent from GC ?</li>
  </ol>
  
  <p>Thanks.</p>