How i get, is user login or logout in facebook sdk 4.0.1

落爺英雄遲暮 提交于 2019-12-05 18:16:46

You could check when the token changes, and if the new access token is null, the user just logged out.

new AccessTokenTracker() {
    @Override
    protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken newAccessToken) {
        if (newAccessToken==null)
            //your code here!
    }
};

Login Updates

Session Removed - AccessToken, LoginManager and CallbackManager classes supercede and replace functionality in the Session class.

Access Tokens - You can load AccessToken.getCurrentAccessToken with the SDK from cache or if the app is cold launched from an app bookmark. For instructions, see Facebook Login for Android, Get Current Token.

Login Button - The easiest way to add Login is to use the LoginButton in 4.x. See Facebook Login for Android, Add Facebook Login.

UserSettingsFragment class has been removed from the SDK.

LoginManager is a singleton instance, and works with the AccessToken's currentAccessToken. After login the SDK sets currentAccessToken. To get additional permissions call the logInWith... methods.

LogInWith... methods always open a prompt UI if necessary. There's no equivalent to the Session.openActiveSessionFromCache or Session.OpenActiveSession(Activity, boolean, StatusCallback). Instead, you should check AccessToken.getCurrentAccessToken() at onCreate(), and if not null, skip login.

AccessToken broadcast events when it is set, unset or updated. Use the AccessTokenTracker to receive these events. See Facebook Login for Android, Track Access Tokens.

currentAccessToken automatically caches when the SDK sets it.

ProfileTracker.getCurrentProfile returns the current logged in user.

ProfileTracker returns events if the logged in user changes. see Facebook Login for Android, Track Current Profile.

CallbackManager.onActivityResult replaces Session.onActivityResult and UiLifecycleHelper.onActivityResult. See Facebook Login for Android, Register a Callback.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!