How to get FB User ID using Facebook Login Button in android application

Anupam picture Anupam · Mar 22, 2013 · Viewed 41k times · Source

I'm developing an application in which I'm using Facebook log in button from SDK. I'm able to get access_token of the user but I want userID too. I have tried almost everything but was not successful. I have used facebook tutorial for achieving that. Here is the link: Facebook Login Button

Please help me in getting userID from the same login button.

Any kind of help will be appreciated.

Answer

Deepika picture Deepika · Apr 3, 2015

Use the getId method of FB Profile class( Facebook SDK 4.0).

  Profile profile = Profile.getCurrentProfile();
  System.out.println(profile.getFirstName());
  System.out.println(profile.getId());