I am following the guide on Processes and Threads to implement an AsyncTask in an android activity in which I will perform some database access. However, my code has to handle an exception in doInBackground.
My current thinking is to provide a Toast popup to inform the user of this exception, but now I am afraid this too “violates the second rule of the single-threaded model: do not access the Android UI toolkit from outside the UI thread” (as per the guide).
Would I be wrong in providing a Toast popup? Is there a better way to handle exceptions in the doInBackground method?
Will the exception cause you to stop what
doInBackgroundis processing?If yes, store what exception you encountered, exit
doInBackgroundand show the Toast inonPostExecuteIf no, pass the exception information to
onProgressUpdatewithpublishProgress.Trying to pop-up the
ToastindoInBackgroundwill not work.