In my application I used an alert dialog box to show 'connection error' message if API call fails. API calls are written with in an AsyncTask. While API is called 'loading' dialog is shown, onPostExecute I will dismiss this 'loading' dilaogue , after that if the API call fails I will show the 'connection error' message.
My problem is while the 'loading' dialog is shown if I press the home button and when I come back to the app, app is in freezed state.
I think the problem is with the 'Connection Error' AlertDailog box,if I remove alertDailog.show,we will not get this issue.
How to solve this?
When the home button is pressed you can choose to cancel the Async task in the onPause() method of the Activity and also close the loading dialog.
When activity resumes (app is brought to foreground), restart your AsyncTask.
This is a good read to your question : http://blog.doityourselfandroid.com/2010/11/14/handling-progress-dialogs-and-screen-orientation-changes/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With