Something that puzzles me since months. Is the following construct save? AsyncTask is an inner class in an Activity. AsyncTask calls a method within the Activity class. This method does not use activity objects or UI calls.
public class MyActivity extends Activity {
private class MyAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected void doInBackground(...) {
longRunningMethod();
}
@Override
protected void onPostExecute(... ) {
}
@Override
protected void onPreExecute (...) {
}
}
private void longRunningMethod() {
// ...
}
}
Safe if not updates the UI, if you’re updating the UI you can use runOnUiThread method.