I don\'t know why, but I am always getting null when I try to get the profile picture of the user. Do I need to set some specific permissions to get access?
Below is
I always received a response stating a FACEBOOK_NON_JSON_RESULT. So looking back in Facebook’s graph API explorer I noted a little checkbox with the label redirect checked. Some googling showed me that I needed to provide a parameter to my GraphRequest that disallows the redirect. Hence the correct request must be:
Bundle params = new Bundle();
params.putBoolean("redirect", false);
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");
//Load picture url in imageView
Glide.with(this).load(picUrlString).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(profilePictureView);
} catch (JSONException | IOException e) {
e.printStackTrace();
}
}
}
).executeAsync();