我正在构建一个Android应用,我试图让用户从Facebook引入照片。在我从GraphRequest获取网址后,我尝试使用Glide将图片加载到ImageButton
,但我一直收到错误D/skia: --- skImageDecoder::Factory returned null
。这是我的代码:
GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
try {
String url = object.getJSONObject("photos").getJSONArray("data").getJSONObject(0).getString("link");
Glide.with(UserSettingsActivity.this).load(url).into(userOne);
} catch (Exception e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields","id,photos{link}");
request.setParameters(parameters);
request.executeAsync();
编辑 - 对不起,我在发帖后意识到我并没有真正提出问题。有谁知道加载Facebook照片的正确方法是什么?谢谢!
答案 0 :(得分:3)
我能够通过将photos{link}
切换为photos{source}
来解决问题,而GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
try {
String url = object.getJSONObject("photos").getJSONArray("data").getJSONObject(0).getString("source");
Glide.with(UserSettingsActivity.this).load(url).into(userOne);
} catch (Exception e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields","id,photos{source}");
request.setParameters(parameters);
request.executeAsync();
会返回实际的源网址。这是修改后的代码:
{{1}}