Getting null bitmap while trying to get Facebook image using Facebook ID

前端 未结 2 1392
误落风尘
误落风尘 2021-01-17 04:00

This is the code I\'m using.

String imageURL;
    Bitmap bitmap = null;

    imageURL = \"http://graph.facebook.com/\" + fbID + \"/picture?type=\";
    try {         


        
2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-17 04:29

    This code works for me with HTTPGet:

                    HttpGet httpRequest = new HttpGet(URI.create(linkUrl) );
                    HttpClient httpclient = new DefaultHttpClient();
                    HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
                    HttpEntity entity = response.getEntity();
                    BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
                    bmap = BitmapFactory.decodeStream(bufHttpEntity.getContent());
                    httpRequest.abort();
    

提交回复
热议问题