@Override protected Void doInBackground(String... params) { answer = "Вернулся " + params[0]; do { try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } System.gc(); try { WeakCallback.get().getResult(answer); } catch (Exception e) { e.printStackTrace(); Log.d(LOG_TAG,"активити пересоздан"); break; } } while (x > 1); return null; } Experimenting. I launched Activity, and through it I switch to the second activation, in it I launch AsyncTask . He turns in an endless loop. I keep the link to the WeakReference in WeakReference I WeakReference activation, for the first activation. AsyncTask continues to work until I start to load the picture and by this I awaken the GC . My activity is removed from memory, I catch an exception and if it is not processed by exiting AsyncTask , AsynckTask will never die (well, until the GC priority reaches it, and until that moment it will consume the charge and memory). And the question itself is whether it is right to use the break statement. Return can not be applied, because the dead activit will turn. Will the break AsyncTask ? From the cycle it goes unequivocally.
doInBackgroundmethoddoInBackgroundpassed to theOnPostExecutemethod. With the correct implementation of the second method, nothing should fall. And note: indoInBackgrounddo not need to contact callbacks, you need to give data for theUIin theOnPostExecutemethod. - post_zeew