How to get Facebook photo, full name, gender using Facebook SDK android

前端 未结 6 1052
闹比i
闹比i 2020-12-13 05:05

I am working on an Android application in which any Android user who is logging to Facebook using our Application, I need to extract his photo, his gender, his full name fro

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 05:29

    With Sdk v4.28 and for logged in Users as on question, it is easy as calling Profile.getCurrentProfile() inside (or after) success callback of LoginManager:

    facebookCallbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(facebookCallbackManager,
                new FacebookCallback() {
                    @Override
                    public void onSuccess(LoginResult loginResult{ 
                        //Profile.getCurrentProfile()
                    }
                    @Override
                    public void onCancel() {
                    }
                    @Override
                    public void onError(FacebookException exception) {
                    }
                });
    

    You could use Graph Api, but doc itself says use above for logged in user.

提交回复
热议问题