AsyncTask and context leaking

Read Time 2 minutesAsyncTask is mostly used as inner class of Activity or Fragment. For example: public class SampleActivity extends Activity { private static SampleActivity instance; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); new SampleTask().execute(); } @Override protected void onPause() { super.onPause(); instance = null; } @Override protected void onResume() { super.onResume(); instance = this; } private …

AsyncTask and context leaking Read More »