先生,如果没有互联网连接,我正在尝试处理该消息。但是如果有任何网络连接,当我仍然继续下载时,就会发生空异常错误。起初,它显示网络连接错误的消息,但当我按下是时,弹出异常错误消息。我们在处理这个案子的时候还需要进一步处理什么?
timer = new Timer();
boolean isOnline = WebServiceHandler.isOnline(this);
if (isOnline) {
startDownloadTask();
task = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
int progress = downloadProgressBar.getProgress();
notification.contentView.setProgressBar(R.id.pb, downloadProgressBar.getMax(), progress, false);
nm.notify(notificationID, notification);
}
};
timer.schedule(task, 10, 500);
} else {
connectionErrorDialog.show();
onDestroy();
}
}
@Override
public void stopDownloadTask() {
downloadGoodListTask.cancel(true);
downloadGoodListTask.setActivityIsRunning(false);
downloadGoodListTask = null;
}
protected void onDestroy() {
super.onDestroy();
Log.i("Download Activity", "starting to destroy");
//timer.cancel();
wheelProgressBar.destroyDrawingCache();
downloadProgressBar.destroyDrawingCache();
finishDialog.dismiss();
connectionErrorDialog.dismiss();
downloadProgressBar = null;
wheelProgressBar = null;
progressTextView = null;
downloadingTextView = null;
finishDialog = null;
connectionErrorDialog = null;
//timer = null;
nm.cancel(notificationID);
nm = null;
notification = null;
/*downloadTask.cancel(true);
downloadTask.activityIsRunning = false;
downloadTask = null;*/
stopDownloadTask();
timer.cancel();
System.gc();
Log.i("Download Activity", "destroyed");
}
@Override
public void stopDownloadTask() {
downloadGoodListTask.cancel(true);
downloadGoodListTask.setActivityIsRunning(false);
downloadGoodListTask = null;
}