获取Facebook个人资料图片时,位图获取为空

时间:2014-01-10 09:58:39

标签: android facebook bitmap

我想通过

获取我的脸谱资料图片
URL fb_pic = new URL("http://graph.facebook.com/"+(facebookuserID)+"/picture?style=small" );

我已成功获取图片网址。但是当我尝试将网址转换为位图时,我没有得到回复,

Bitmap bit = BitmapFactory.decodeStream(fb_pic.openConnection().getInputStream());

请给我一个解决方案...... !!!

1 个答案:

答案 0 :(得分:2)

此代码对我有用

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

httpRequest.abort();