I want to show the users profile picture in a list view. When I try to call the graph-api from android to retrieve the image, I always get the following error.
<
Use below code to get user profile image with Facebook Graph API
.
ImageView profileImage = (ImageView) findViewById(R.id.profileImage);
Bundle params = new Bundle();
params.putBoolean("redirect", false);
params.putString("type", "large");
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"me/picture",
params,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
try {
String picUrlString = (String) response.getJSONObject().getJSONObject("data").get("url");
Glide.with(getApplicationContext()).load(picUrlString).placeholder(R.drawable.ic_launcher).into(profileImage);
} catch (JSONException | IOException e) {
e.printStackTrace();
}
}
}
).executeAsync();
And more information refer This
Simple to get user image
String UserImageUrl="https://graph.facebook.com/" + facebookUser.getFacebookID() + "/picture?type=large";
Glide.with(getApplicationContext()).load(UserImageUrl).placeholder(R.drawable.ic_launcher).into(profileImage);