我正在开发一个应用程序,我已经使用我的Facebook帐户登录了。我在从facebook个人资料中获取封面照片并在ImageView中设置时遇到问题。我尝试按照本指南进行操作:https://developers.facebook.com/docs/graph-api/reference/v2.7/cover-photo/#Overview但是每次运行应用程序时都会崩溃。有谁知道我做错了什么?
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"...?fields={fieldname_of_type_CoverPhoto}",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
URL cover = response.getConnection().getURL();
try {
Bitmap coverPicture = BitmapFactory.decodeStream(cover.openConnection().getInputStream());
Toast.makeText(ProfilActivity.this, "bitmap" + coverPicture, Toast.LENGTH_SHORT).show();
ImageView coverS = (ImageView) findViewById(R.id.cover);
coverS.setImageBitmap(coverPicture);
} catch (IOException e) {
e.printStackTrace();
}
Toast.makeText(ProfilActivity.this, "URL" + cover, Toast.LENGTH_SHORT).show();
}
}
).executeAsync();