Life Cycle Methods and AsyncTask

What will happen if a user clicks the Back button when a progress dialog initiated by an async task is visible? This will cancel the dialog as per UI guidelines. However, if you don't take the precaution of also cancelling the async task, it will continue to run. So a good practice is to capture the oncancel of the dialog and explicitly cancel the async task.

What happens if you are not using a progress dialog but are the progress through some other means on the activity? What happens if a user navigates away from the activity either through a Back button or a press on the Home key? In both these cases, there is no expectation that the user will come back any time soon. Many times, the right thing to do is recognize ...

Get Pro Android 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.