Search code examples
androidfacebookfacebook-android-sdkfacebook-permissions

Facebook android app permission: ask for get user profile picture


i'm write android app that use facebook api, and i need that my app can retrieve user profile picture.

This is my current permissions:

fb_login_button.setReadPermissions(Arrays.asList("public_profile", "user_friends"));

but i don't see in documentation any permission for get user profile picture, but only permission for access to ALL pictures (i'm not interested about it). So, profile picture is now accessible without any permission


Solution

  • The public_profile permission does give you profile picture as well.

    This is how you will get the profile picture

    public static Bitmap getFacebookProfilePicture(String userID){
    URL imageURL = new URL("https://graph.facebook.com/" + userID + "/picture?type=large");
    Bitmap bitmap = BitmapFactory.decodeStream(imageUrl.openConnection().getInputStream());
    
    return bitmap;
     }
    
     Bitmap bitmap = getFacebookProfilePicture(userId);
    

    Refer: Android - get facebook profile picture