我不知道为什么,但我总是得到空当我尝试获取用户的个人资料图片。我是否需要设置一些权限可以访问?
I don't know why, but I am always getting null when I try to get user profile picture. Am I need to set some permission 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 why.
这应该工作:
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);
所建议的@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".
上一篇:DownloadManager.ACTION_DOWNLOAD_COMPLETE广播接收机接收相同的下载ID具有不同的下载状态在Android中不止一次接收机、状态、不同、DownloadManage
下一篇:固定纵横比查看