How to handle feedback from background threads if the user uses the back button?
Posted
by Janusz
on Stack Overflow
See other posts from Stack Overflow
or by Janusz
Published on 2010-03-31T11:11:31Z
Indexed on
2010/03/31
11:13 UTC
Read the original article
Hit count: 195
I have the following problem:
I have an Activity where a user can start a web search showing a new activity to show a progress bar until the results are shown. Now the user can either wait for the results or maybe think about the search parameters, hit the back button and triggering a new search. The search is running in an Async Task and therefor still running if the user hits back. At the moment the thread finishes it calls some methods on the old activity causing the activity to show a dialog.
This causes the system to crash because the dialog tries to show itself with a reference to an activity that is not longer present on the screen.
How can I achieve a dialog that is only shown if the activity is still active?
© Stack Overflow or respective owner