Android Alert Dialog

In my application, I used the alert dialog to show a connection error message if the API call failed. API calls are recorded in AsyncTask. While the API is called a “downloadable” dialog, onPostExecute I reject this “loading” dilaogue, after which, if the API call failed, I will display a “communication error” message.

My problem is that while the download dialog is displayed, if I click the home button, and when I return to the application, the application is in a frozen state.

I think the problem is with the AlertDailog "Connection Error" checkbox, if I remove alertDailog.show, we will not get this problem.

How to solve this?

+5
source share
1 answer

When you click the home button, you can cancel the Async task in the onPause () Activity method, as well as close the download dialog.

When activity resumes (application moved to the forefront), restart your AsyncTask.

This is a good read for your question: http://blog.doityourselfandroid.com/2010/11/14/handling-progress-dialogs-and-screen-orientation-changes/

+2
source

All Articles