Your code looks fine to me. I have used similar code without problem. Is it possible that some of your images are corrupt?
Check the logs. When BitmapFactory.decodeStream() returns null it logs a single-line error message such as: 04-04 00:55:14.184: DEBUG/skia(31069): xxxxxxxxxxx jpeg error 53 Not a JPEG file: starts with 0x%02x 0x%02x This typically means that your image is bad. You can also try downloading the image yourself, storing it in a byte array and use decodeByteArray(). By downloading the image yourself you can make sure that it is of the proper size (that you have downloaded as many bytes as the content length) and that no IOExceptions occurred during the download. You can then write the image to a file and try to open it yourself if decodeByteArray() returns null. Hope that helps, Greg On Apr 3, 4:08 am, "Muthu Kumar K." <[email protected]> wrote: > Hi All, > I am trying to download the image from the server. Here i am getting > the problem, some times the image is not getting download it is > showing empty. In server i kept the bitmap image. I am using the > following code to download the image. > > private Bitmap downloadImageFile(String fileUrl) { > URL myFileUrl = null; > try { > myFileUrl = new URL(fileUrl); > } catch (MalformedURLException e) { > e.printStackTrace(); > } > try { > HttpURLConnection conn = (HttpURLConnection) > myFileUrl.openConnection(); > conn.setDoInput(true); > conn.connect(); > int length = conn.getContentLength(); > InputStream is = conn.getInputStream(); > bmImg = BitmapFactory.decodeStream(is); // some times > im getting > this as null > } catch (IOException e) { > e.printStackTrace(); > bmImg = null; > } > return bmImg; > } > > Please give me your suggestions. > > Thanks in Advance, > Muthu Kumar K. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

