-4

I want to get profile picture and User Name of user which login in android app and set in Imageview

i am not getting how to get profile picture.

Thanks Advance

user
  • 471
  • 2
  • 16
  • 31
  • Refer this question http://stackoverflow.com/questions/6706977/how-to-get-the-facebook-profile-picture-in-my-android-application and also http://stackoverflow.com/questions/10094609/android-getting-all-users-friend-profile-pictures-quicly – Chintan Soni Apr 29 '13 at 14:14
  • [Have a look at this post](http://stackoverflow.com/a/10245654/593709) – Adil Soomro Apr 29 '13 at 14:15

1 Answers1

16

Just use the facebook ProfilePictureView instead of an image view:

<com.facebook.widget.ProfilePictureView
   android:id="@+id/friendProfilePicture"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:gravity="center_horizontal"
   android:padding="5sp"
   facebook:preset_size="small" />

You can set the size to small/normal/large/custom.

Then in your code, set the user facebook id like this:

ProfilePictureView profilePictureView;
profilePictureView = (ProfilePictureView) findViewById(R.id.friendProfilePicture);
profilePictureView.setProfileId(userId);

Hope this help.

Damien R.
  • 3,383
  • 1
  • 21
  • 32
  • What is userId and i have also get User name? – user Apr 29 '13 at 14:21
  • When you get logged to facebook, you get an User object in callback. You can found the facebook user id in this object: user.getId(); To get name information you can use those functions: user.getFirstName(); user.getLastName(); user.getName(); – Damien R. Apr 29 '13 at 14:27
  • 04-29 20:42:14.480: W/System.err(11630): java.io.FileNotFoundException: http://graph.facebook.com/1251935507/pictures getting this exception while getting profile picture if user: – user Apr 29 '13 at 15:18
  • @DamienR. Hey is that a library that i should include in my build.gradle? – Antonios Tsimourtos Mar 11 '17 at 12:32