我正在使用AsyncTask
以下载我的活动中的图像
流程是这样的:
protected void onPreExecute() {
\\begin animation
}
protected IUpiResponse doInBackground(String... params) {
\\ download the image
}
protected void onPostExecute(IUpiResponse upiResponse) {
\\stop the animation
}
直到这里一切都很好,如果我在异步任务工作时进入后台,问题就开始了,有时我在动画停止时得到一个异常空指针,因为视图不再有效(我猜),
如果活动在前台,我可以在停止动画之前检查,但我更喜欢避免这种方法,我还能做什么?