Android App FB登录..

时间:2016-11-12 07:29:45

标签: android facebook sdk facebook-android-sdk facebook-access-token

我已在我的应用中集成了FB登录。我可以通过FB登录登录我的应用程序。即使用户已通过FB登录,然后当他重新启动我的应用程序时,他不必再次登录,并且他将显示登录页面。为此,我添加了以下代码:

@覆盖

protected void onResume() {
    super.onResume();
    if (AccessToken.getCurrentAccessToken() != null && !AccessToken.getCurrentAccessToken().isExpired()) {
        Profile profile = Profile.getCurrentProfile();
        // if the user already logged in, try to show the selection fragment
        login(profile);
    }
}

但是当我从FB App退出后重新启动我的应用程序时,我仍然能够登录我的应用程序并登陆页面(登录后显示的页面)显示。

我想要如果我已经退出FB应用程序,那么我的应用程序应该再次显示登录页面,要求使用FB或通过电子邮件登录应用程序。但即使我从fb注销,我的登录页面也会从onResume代码启动。我应该添加什么代码来了解用户是否已注销FB应用程序?

任何帮助都会非常感激.. !!!

2 个答案:

答案 0 :(得分:0)

您可以将访问令牌保存到sharedPrefrences中,并使用此值来避免使用reLogin应用程序而不是AccessToken类。 然后你可以在注销事件中清除你的sharedPrefrence。

答案 1 :(得分:0)

There's no mechanism for what you're asking for.

The FB app is disjoint from your app. It's there to be an authenticator, but once someone is logged in, then they're logged in to YOUR app, and the FB app is now out of the loop.

Logging out (or switching users) on the FB app does not have any effect on anyone's logged in status on your app.