获得零位,同时试图让使用Facebook的ID Facebook的图片零位、图片、Facebook、ID

2023-09-07 01:22:56 作者:忘记过往

这是在code我使用。

This is the code I'm using.

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();
    }

当我使用这个网址,浏览器,它显示的图像,但试图得到它的位图时,它给了空。

when i use this URL in browser it shows image, but when trying to get it in bitmap it gives null.

我检查了很多的问题,但没有帮助我。

I've checked many question, but nothing help me.

推荐答案

这code工作对我来说与HTTPGET:

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();