Android – If an activity is killed, does the AsyncTask live on

androidandroid-asynctask

I think I know the answer to this, but does an AsyncTask continue to live on once its calling Activity has been finish()ed?

    protected void onPreExecute() {
        Toast.makeText(getApplicationContext(), "Your data is processing.", Toast.LENGTH_LONG);
        finish();
    }

Edit: so far two different answers 🙂

Best Answer

The AsyncTask is tied to a UI thread and if the Activity is finished the async task is canceled.

[update] - Hackbod's comment below is correct. It should be noted that AsyncTasks are meant to be short lived and as such not worry so much about this issue. An AsycTask is only truly gone when it is completed OR the process is killed which may or may not happen after finish is called.