0
我有2案件BitmapFactory解碼流returing空,而使用InputStream讀入
第一種情況
在這種情況下,圖像顯示,但進度對話框不顯示
URL url = new URL(params[0]);
connection = (HttpsURLConnection) (url.openConnection());
connection.setRequestMethod("GET");
connection.connect();
int fileSize = connection.getContentLength()/1000;
stream = connection.getInputStream();
image = BitmapFactory.decodeStream(stream);
while((b = stream.read(data))!=-1)
{
total += b/1000;
publishProgress(String.valueOf(total)+" kb/"+String.valueOf(fileSize)+"kb");
}
return image;
登錄
D/ImageDownload: doInBackground: [email protected]
第二種情況 在這種情況下進度對話框中顯示,但圖像沒有顯示
URL url = new URL(params[0]);
connection = (HttpsURLConnection) (url.openConnection());
connection.setRequestMethod("GET");
connection.connect();
int fileSize = connection.getContentLength()/1000;
stream = connection.getInputStream();
while((b = stream.read(data))!=-1)
{
total += b/1000;
publishProgress(String.valueOf(total)+" kb/"+String.valueOf(fileSize)+"kb");
}
image = BitmapFactory.decodeStream(stream);
Log.d(TAG, "doInBackground: "+String.valueOf(image));
return image;
登錄
D/ImageDownload: doInBackground: null