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?
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.
boolean
false
onPostExecute()
AsyncTask
onBackPressed
Activity
!= true
Source: https://ru.stackoverflow.com/questions/476968/More articles:combinatorial problemHow to find out information about the file in the archive, knowing the path? SevenZipSharpHow to parse data from webviewAjax navigation and code highlighting from prismjs.comHow to make svayp work back in UINavigationController along with DrawerController?Password retriever, freezes programCheck PHP functionDISTINCT ON in the Zend FrameworkHow to prevent duplicate checkmarker by clicking on a cell in the table?How to organize a collection with the ability to add both to the beginning and to the end?All Articles