0
我正在构建一个android应用程序,我需要从一个URL下载一个gif图像并存储在一个字节数组中。一直使用位图工厂类,但它一直返回null。我将字节数组存储到sqlite然后检索并显示。下载Streamed gif文件并存储在字节数组中
urlConnection = (HttpURLConnection) url.openConnection();
InputStream is = urlConnection.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
//We create an array of bytes
byte[] data = new byte[4094];
int current = 0;
while((current = bis.read(data,0,data.length)) != -1){
buffer.write(data,0,current);
}
我甚至试图转换使用Bitmap.Factory,但返回空值。