使 Facebook SDK 缓存用户的凭据



是否可以使Facebook SDK缓存用户的登录/密码?目前,每次运行该应用程序时,我都必须输入凭据。我使用登录按钮的标准登录方式。

在我的活动中:

    FacebookSdk.sdkInitialize(getApplicationContext());
    setContentView(R.layout.activity_main);
    callbackManager = CallbackManager.Factory.create();
    LoginButton loginButton = (LoginButton);
    this.findViewById(R.id.login_button);
    loginButton.registerCallback(callbackManager,this);

您应该在活动的onResume()onCreate()中具有以下代码

AccessToken accessToken = AccessToken.getCurrentAccessToken();
if (accessToken!=null) {
         Profile profile=Profile.getCurrentProfile();
         nextActivity(profile);
}else{
         //Launch FB login
}

最新更新