@Override
protected Bitmap doInBackground(String... params) {
Bitmap bitmap=null;
ByteArrayOutputStream outputStream=new ByteArrayOutputStream();
InputStream inputStream=null;
try {
HttpClient httpClient=new DefaultHttpClient();
HttpGet httpGet=new HttpGet(params[0]);
HttpResponse httpResponse=httpClient.execute(httpGet);
if (httpResponse.getStatusLine().getStatusCode()==200) {
inputStream=httpResponse.getEntity().getContent();
long file_length=httpResponse.getEntity().getContentLength();
int len=0;
byte[] data=new byte[1024];
int duqulength=0;
while((len=inputStream.read(data)) != -1){
duqulength +=len;
int values=(int) ((duqulength/file_length)*100);
publishProgress(values);
System.out.println(values);
outputStream.write(data, 0, len);
}
byte[] date1=outputStream.toByteArray();
bitmap=BitmapFactory.decodeByteArray(date1, 0, date1.length);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}finally {
if (inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return bitmap;
}
}
这个是代码 为什么进度条不更新啊 就最后一下子变100