title: WeakReference in AsyncTask got nullified despite the Activity is still shown
body: <p>I followed the pattern of using WeakReference in AsyncTask by assigning a weak reference in the constructor:</p>
  
  <pre><code>private final WeakReference&lt;WeakClass&gt; weakRef;
  
  public WeakRefAsyncTask( @NotNull WeakClass _weakClassInstance ) {
  
      weakRef = new WeakReference&lt;&gt;( _weakClassInstance );
  }
  
  protected final @NonNull WeakClass getWeakOne() {
  
      WeakClass o = weakRef.get();
  
      if( o != null ) {
  
          return o;
      } else {
  
          throw new WeakRefIsNullException( getTaskDetailsDescription() );
      }
  }
  </code></pre>
  
  <p>But now I get another issue - the weak reference now and again gets nullified even though the activity is still working (DoWeaklyAsyncTask being static inner descendant from WeakRefAsyncTask within AbstractPurchaseListActivity).</p>
  
  <pre><code>03-19 11:02:19.632 5184-5305/com.tsarsprocket.purchaselist.subscribe E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #5
  Process: com.tsarsprocket.purchaselist.subscribe, PID: 5184
  java.lang.RuntimeException: An error occured while executing doInBackground()
      at android.os.AsyncTask$3.done(AsyncTask.java:300)
      at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
      at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
      at java.util.concurrent.FutureTask.run(FutureTask.java:242)
      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
      at java.lang.Thread.run(Thread.java:818)
   Caused by: com.tsarsprocket.DroidTools2.tools.WeakRefAsyncTask$WeakRefIsNullException: Weak reference is null. Task details:
  Loading names already used in purchase list version, id=-1
      at com.tsarsprocket.DroidTools2.tools.WeakRefAsyncTask.getWeakOne(WeakRefAsyncTask.java:37)
      at com.tsarsprocket.purchaselist.core.AbstractPurchaseListActivity$DoWeaklyAsyncTask.doWeakInBackground(AbstractPurchaseListActivity.java:225)
      at com.tsarsprocket.DroidTools2.tools.WeakRefAsyncTask.doInBackground(WeakRefAsyncTask.java:118)
      at android.os.AsyncTask$2.call(AsyncTask.java:288)
      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
          ... 4 more
  </code></pre>
  
  <p>The problem is that the activity is still actual when the weakref is nullified and still needs the results of the acynctask. I suspect this is because of aggressive GC maybe. And the task cannot tell the activity that it failed because the weakref was the only link.</p>
  
  <p>Is there any way to efficiently use weakrefs in asynctasks AND to prevent the asynctasks from failing due to weakref nullification please?</p>