从输入流下载图像显示损坏的图像

时间:2018-10-17 01:58:22

标签: android

此图像显示损坏。在所有下载过程中,它只会偶尔发生一次。我需要一些建议来克服和解决此问题 enter image description here

 String fullUrl = ServerUrl + DomainConstantValues.IMAGE_LOCATION_POST + postImage.getPost_id() + "/" + postImage.getImage_path();
            Log.d("getReceveiver", "DownloadImagesPost: url " + fullUrl);
            //Download Image from URL
            InputStream input = new java.net.URL(fullUrl).openStream();
            Log.d("getReceveiver", "DownloadImagesPost: " + input);
            //Decode Bitmap
            bitmap = CommonFunctions.readBitmapFromByte(input);
            if (bitmap == null) {
                Log.d("getReceveiver", "DownloadImagesPost: ");
            }


 public static Bitmap readBitmapFromByte(InputStream input) {
    if (input != null) {
        Bitmap bitmap = BitmapFactory.decodeStream(input);

        return bitmap;
    }
    return null;
}

0 个答案:

没有答案