Hi ,
 i have a display an image from server, for which  have an imageurl,
i have used the below code:

downloadImage(image_url);








private void downloadImage(String urlStr) {
 InputStream in = null;
 try {
    in = openHttpConnection(urlStr);
    bitmap = BitmapFactory.decodeStream(in);
    System.out.println("bitmap  val  "+bitmap);
    img.setImageBitmap(bitmap);
   ;
    in.close();
} catch (IOException e1) {
    e1.printStackTrace();
}

}

 private InputStream openHttpConnection(String urlStr) {
InputStream in = null;
int resCode = -1;
 try {
URL url = new URL(urlStr);
URLConnection urlConn = url.openConnection();
 if (!(urlConn instanceof HttpURLConnection)) {
throw new IOException ("URL is not an Http URL");
}
 HttpURLConnection httpConn = (HttpURLConnection)urlConn;
httpConn.setAllowUserInteraction(false);
           httpConn.setInstanceFollowRedirects(true);
           httpConn.setRequestMethod("GET");
           httpConn.connect();

           resCode = httpConn.getResponseCode();
           if (resCode == HttpURLConnection.HTTP_OK) {
               in = httpConn.getInputStream();

           }
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return in;
}

either the bitmap is null or  i get the below error
: --- decoder->decode returned false

-- 
 Regards,
Vani Reddy

-- 
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

Reply via email to