You need to wait until the AsyncTask is completed without blocking the main thread so that you cannot exit the Activity by pressing Back.

How to achieve this?

    1 answer 1

    Get a boolean flag, set the default to false , and on onPostExecute() AsyncTask set it to true and override onBackPressed in Activity so that the != true flag does nothing.