Android - get facebook profile picture

后端 未结 28 2330
花落未央
花落未央 2020-12-12 15:13

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

28条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 15:46

    Best way to Get Profile Picture URL

    int dimensionPixelSize = getResources().getDimensionPixelSize(com.facebook.R.dimen.com_facebook_profilepictureview_preset_size_large);
    Uri profilePictureUri= Profile.getCurrentProfile().getProfilePictureUri(dimensionPixelSize , dimensionPixelSize);
    

    or

    Uri profilePictureUri = ImageRequest.getProfilePictureUri(Profile.getCurrentProfile().getId(), dimensionPixelSize , dimensionPixelSize );
    

    Use Glide to show Image

    Glide.with(this).load(profilePictureUri)
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    .into(profilePictureView);
    

    No more hard-coded string

提交回复
热议问题