【发布时间】:2014-04-07 08:54:18
【问题描述】:
我使用了 facebook 3.6 sdk 。我想从图形用户那里获取个人资料图片,上次我得到了图像,但现在它返回空位图。
我使用了以下代码
private void onSessionStateChange(Session session, SessionState state,
Exception exception) {
if (session.isOpened()) {
Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
try {
URL imgUrl = new URL("http://graph.facebook.com/"
+ user.getId() + "/picture?type=large");
InputStream in = (InputStream) imgUrl.getContent();
Bitmap bitmap = BitmapFactory.decodeStream(in);
//Bitmap bitmap = BitmapFactory.decodeStream(imgUrl // tried this also
//.openConnection().getInputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}).executeAsync();
}
}
当我使用直接链接时,它可以工作。
imgUrl = new URL("https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.2365-6/851558_160351450817973_1678868765_n.png");
我也提到了这个Graph API Reference
【问题讨论】:
标签: android facebook facebook-graph-api facebook-android-sdk