Android - 获取Facebook个人资料图片 [英] Android - get facebook profile picture
本文介绍了Android - 获取Facebook个人资料图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道为什么,但是当我尝试获取用户的个人资料图片时,我总是变空。我需要设置一些特定权限才能访问?
I don't know why, but I am always getting null when I try to get the profile picture of the user. Do I need to set some specific permissions to get access?
以下是我的方法:
public static Bitmap getFacebookProfilePicture(String userID) throws SocketException, SocketTimeoutException, MalformedURLException, IOException, Exception
{
String imageURL;
Bitmap bitmap = null;
imageURL = "http://graph.facebook.com/"+userID+"/picture?type=large";
InputStream in = (InputStream) new URL(imageURL).getContent();
bitmap = BitmapFactory.decodeStream(in);
return bitmap;
}
Bitmap bitmap = getFacebookProfilePicture(userId);
我变空我不知道为什么?任何帮助都是可以理解的。
I am getting null. I don't know the reason why? Any help is appreciable.
推荐答案
这应该有效:
public static Bitmap getFacebookProfilePicture(String userID){
URL imageURL = new URL("https://graph.facebook.com/" + userID + "/picture?type=large");
Bitmap bitmap = BitmapFactory.decodeStream(imageURL.openConnection().getInputStream());
return bitmap;
}
Bitmap bitmap = getFacebookProfilePicture(userId);
编辑:
在评论中,href =https://stackoverflow.com/questions/19855072/android-get-facebook-profile-picture#comment34682218_19855492> @dvpublic ,图像未被下载的问题是使用https赞成http。
As suggested by @dvpublic in the comments, the problem of image not being downloaded is fixed using by "https" in favour of "http".
这篇关于Android - 获取Facebook个人资料图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文