Get user image from Facebook Graph-API

前端 未结 7 640
长发绾君心
长发绾君心 2020-12-01 03:22

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.

<         


        
7条回答
  •  没有蜡笔的小新
    2020-12-01 03:31

    There is an easy way to get facebook user image for logged in user.

    To make the code work add this import statement:

    import com.facebook.Profile;
    

    See example below (in this example I use Picasso library to set image):

    Uri imageUri = Profile.getCurrentProfile().getProfilePictureUri(400, 400);
    Picasso.with(this).load(imageUri).into(imageView);
    

    Numbers 400 and 400 are image width and height respectively.

提交回复
热议问题