@Override
protected Boolean doInBackground(String... params) {
// TODO Auto-generated method stub
System.out.println("[downloadImageTask->]doInBackground "
+ params[0]);
// try {
// mDownloadImage = HttpUtils.getNetWorkBitmap(params[0]);
// } catch (MalformedURLException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
try {
mDownloadImage = HttpUtils.getHttpGetBitmap(params[0]);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
// 下载完成回调
@Override
protected void onPostExecute(Boolean result) {
// TODO Auto-generated method stub
image.setImageBitmap(mDownloadImage);
System.out.println("result = " + result);
super.onPostExecute(result);
}
// 更新进度回调
@Override
protected void onProgressUpdate(Integer... values) {
// TODO Auto-generated method stub
super.onProgressUpdate(values);
}
}
}
如果图片较大可能会下载失败