0

I want to get the profile details from Facebook. I am using the latest Facebook SDK. I want to use custom login button to login and get profile details of user.

In onSuccess method i am getting LoginSuccess object . Now i am stuck how i got user profile data . And this code is on facebookButton not on custom button. Please give me some ideas to integrate the SDK via custom button. I go through the facebook documentation but do not got anything useful.

callbackManager = CallbackManager.Factory.create();

LoginManager.getInstance().registerCallback(callbackManager,
    new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            // App code
        }

        @Override
        public void onCancel() {
            // App code
        }

        @Override
        public void onError(FacebookException exception) {
            // App code
        }
    }
);
Darek Kay
  • 15,827
  • 7
  • 64
  • 61
Ratna deep verma
  • 141
  • 1
  • 11

1 Answers1

0

You can get simple user info (like name and id) by using in onSuccess() loginManager method Profile class:

Profile.getCurrentProfile() //get current instance of logged profile
Profile.getCurrentProfile().getId() //get current id
Profile.getCurrentProfile().getName() //get current user name

If you want to fetch more information about user, like email or date of birth, you should to use GraphAPI request. You can read about it in related question answer.

It doesn't matter, if you are using Custom Login button or not. In both situations SDK is using loginManager.

Community
  • 1
  • 1
VadymVL
  • 5,366
  • 3
  • 26
  • 41