Issue
After an AsyncTask finishes, I usually do one of the following;
- Call a method on a callback object/interface that I define in the activity and pass to My AsyncTask subclass constructor.
- Provide the AsyncTask with a Handler and call myHandler.sendMessage() when the task is complete.
What I want to ask is what is considered best practice after the AsyncTask is complete. If the user has pressed the home button while the task is processing, the activity is no longer in the foregreound. As soon as the app tries some UI operation, as a response to the task beeing completed, the The OS throws a WindowManager$BadTokenException.
I can of course surround my UI code with a catch for BadTokenException. That seems hacky. Is there any way to tell if the activity is in front?
Solution
It means you are using some where the context that is not appropriate. To clear you doubt about the exception see this Link. Bad Token Exception
Answered By - Lalit Poptani
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.