【发布时间】:2015-08-17 10:00:59
【问题描述】:
loginBtn.setUserInfoChangedCallback(new UserInfoChangedCallback() {
@Override
public void onUserInfoFetched(GraphUser user) {
if (user != null) {
userName.setText("Hello, " + user.getName());
Bitmap bitmap1 = getFacebookProfilePicture(user.getId());
imgview.setImageBitmap(bitmap1);
} else {
userName.setText("You are not logged");
}
}
});
public Bitmap getFacebookProfilePicture(String userID) {
try {
URL imageURL = new URL("https://graph.facebook.com/" + userID
+ "/picture?type=large");
bitmap = BitmapFactory.decodeStream(imageURL.openConnection()
.getInputStream());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bitmap;
}
这是我的代码,我正在尝试从 Facebook 获取个人资料图片并将其显示在我的应用程序的图像视图上,我可以从 Facebook 获取名称,但是当我输入获取个人资料图片的代码时,我无法获取图片在android中请告诉我哪里做错了给我解决方案如何设置这个代码。
【问题讨论】:
-
您正在尝试在 UI 线程上发出 HTTP 请求 [
getFacebookProfilePicture]... 查看 Logcat 错误