title: Why have a static weakreference to service object?
body: <p>I've come across this android code below. Is there ever a use case of creating a static weakreference object in a service to get its reference? I know that static variables are not eligible for Garbage collection. In general, Does creating a weak reference of any static variable change its gc properties?</p>
  
  <p>for example:</p>
  
  <pre><code>private static WeakReference&lt;MyService&gt; mService;
  public static MyService getInstance(){
      if(mService != null){
            return mService.get();
      } 
      return null;
  }
  </code></pre>
  
  <p>And in my onCreate</p>
  
  <pre><code>public void onCreate(){
     super.onCreate();
     mService = new WeakReference&lt;MyService&gt;(this);
  }
  </code></pre>