WeakReference in AsyncTask
Check for null in WeakReference everytime you need to use it is necessary because the GC process can clear the instance anytime during your work. Besides, onPreExecute, onPostExecute and doInBackground is run in the different thread, there is also some delay when changing thread and the instance may be cleared in between too.

I have a helper method that does the check for null in WeakReference and its instance. Use it if you like:

public &lt;T&gt; T getInstance(WeakReference&lt;T&gt; weakReference) {
    if (weakReference == null || weakReference.get() == null)
        return null;

    // Do more check for your activity if need

    return weakReference.get();
}