Hi All,

In my app I am downloading images from a remote server and putting it
into a gallery and displaying it. The problem is that when i do it on
the emulator it works absolutely fine but when i do it on the phone
few of the images come and a few are null. I tried many ways but I am
not able to find the perfect way. The images on my server are of 50 kb
max. But still some are downloaded and rest are not. it would be
really great if someone could help me asap coz i need to make this app
live by this weekend.

Here is the code snippet to download the images from the server.

public Bitmap getImage(String photoUrl) {
                Bitmap image = null;
                if (!photoUrl.equals("")) {
                        if(photoUrl.contains(" ")) {
                                photoUrl = photoUrl.replaceAll(" ", "%20");
                        }
                                try {
                                        URLConnection conn = new 
URL(photoUrl).openConnection();
                                        conn.connect();
                                        InputStream inStream = 
conn.getInputStream();
                                        BufferedInputStream bis = new 
BufferedInputStream(inStream);

                                        image = BitmapFactory.decodeStream(bis);

                                        bis.close();
                                        inStream.close();
                                } catch (MalformedURLException e) {
                                        e.printStackTrace();
                                } catch (IOException e) {
                                        image = 
BitmapFactory.decodeResource(getResources(),
R.drawable.image_not_available);
                                }
                } else {
                        image = BitmapFactory.decodeResource(getResources(),
R.drawable.image_not_available);
                }
                return image;
        }


Also is there any other way of loading the images in a seperate thread
like it happens in the android market.
please reply.

Thanks
Pulkit

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to