Nevaeh
Nevaeh

Reputation: 1569

How to display logged in user's profile picture in android app using ProfilePictureView from Facebook SDK?

I want to display the profile picture of a logged in user in my android app.How to do that using the method ProfilePictureView in Facebook SDK?Please help...

Upvotes: 0

Views: 1220

Answers (1)

Leo
Leo

Reputation: 14820

If you want to display the user's photo using the CircularImageView library. You can still make requests to the Facebook Graph API and parse the response by yourself. You can do this manually or using the Android SDK for Facebook by making a request to the following endpoint...

graph.facebook.com/v2.1/me/picture

of course, you can replace me by a specific user's id. You don't need to request any special permissions in the access token. The request about will render a json response similar to the one below...

{
  "data": {
    "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash2/v/t1.0-1/blahblahblah_n.jpg?oh=2xgdgfdhgdhdhg33ba58e021&oe=5dghgdh_gda__=1dgfhdfh88_b9gdhfghfghfghfghfgh408d6e7", 
    "is_silhouette": false
  }
}

this json response contains the following fields:

  1. url: which is a url from where you can request the profile picture
  2. is_silhouette: which determines whether the picture is the default facebook silhouette or not. If the user has not added a profile picture, then the facebook default silhouette will be returned in the url...see below

enter image description here

You can also use the Android SDK for Facebook, create a request object, pass in the current session object, execute the request asynchronously, for example...

new Request(
    _currentSession,
    "/me/picture",
    null,
    HttpMethod.GET,
    new Request.Callback() {
        public void onCompleted(Response response) {
            //parse the response
        }
    }
).executeAsync();

For more information you can read the documentation on their site and even use the Graph API Explorer for testing purposes

Upvotes: 1

Related Questions