Am using AsyncTask
in order to download images within my activity
the flow goes like this:
protected void onPreExecute() {
\\begin animation
}
protected IUpiResponse doInBackground(String... params) {
\\ download the image
}
protected void onPostExecute(IUpiResponse upiResponse) {
\\stop the animation
}
till here everything fine, the problem start if i go to background while the asynctask is working sometimes I get an exception nullpointer in the animation stops, because the views no longer valid (i guess),
I can check before the stop animation if the activity is in foreground but i prefer to avoid this approach, what else i can do ?
try {} catch{}
? – MeghanmeghannAsyncTask
does not run on UI thread, therefore you cannot access/update Views directly from thedoInBackground()
. – Intubate