尝试使用Facebook ID获取Facebook图像时获取空位图

Ank*_*kit 0 android facebook bitmap

这是我正在使用的代码.

String imageURL;
    Bitmap bitmap = null;

    imageURL = "http://graph.facebook.com/" + fbID + "/picture?type=";
    try {
        bitmap = BitmapFactory.decodeStream((InputStream) new URL(imageURL)
                .getContent());

    } catch (Exception e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

当我在浏览器中使用此URL时,它会显示图像,但是当尝试在位图中获取它时,它会给出null.

我检查了很多问题,但没有任何帮助.

fr4*_*r4n 5

这段代码适用于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();
Run Code Online (Sandbox Code Playgroud)