开发者

Class cast exception while loading image from webbu

Hello All I am trying to load image from web but I am getting Exception

java.lang.ClassCastException: org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl$LimitedInputStreamm

My code for loading image is

private Drawable loadImageFromWebOperations(String url)
  {
              Log.i("WHERE","MenuPage loadImageFromWebOperations()");
          try
               {
                       InputStream is = (InputStream) new URL(url).getContent();
                       Drawable d = Drawable.createFromStream(is, "src name");
                       return d;
               }
          catch (Exception e) 
               {
                       System.out.println("loadImageFromWebOperations ="+e);
                        Log.v("EXCEPTION AT ","FriendActivity loadImageFromWebOperations()");
                       return null;
              开发者_如何学运维 }
       }

Plz Help Me Thanks in Advance


use this method to download image.

  HttpGet httpRequest = null;
            httpRequest = new HttpGet(url);
            HttpClient httpclient = new DefaultHttpClient();
            HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
            HttpEntity entity = response.getEntity();
            BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity); 
            InputStream instream = bufHttpEntity.getContent();
            bitmap= BitmapFactory.decodeStream(instream);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜