Profile.getCurrentProfile() returns null after logging in (FB API v4.0)

前端 未结 4 1844
生来不讨喜
生来不讨喜 2020-12-08 06:44

For some reason Profile.getCurrentProfile() shows up null at times right after logging into FaceBook, using FB API v4.0.

This is causing problems for me

4条回答
  •  渐次进展
    2020-12-08 07:01

    Following to Sufian's answer, you can also save the new profile to Profile class:

    @Override
    public void onSuccess(LoginResult loginResult) {
        ProfileTracker profileTracker = new ProfileTracker() {
            @Override
            protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
                this.stopTracking();
                Profile.setCurrentProfile(currentProfile);
    
            }
        };
        profileTracker.startTracking();
    }
    

提交回复
热议问题