0

现在我正在使用 android Facebook 集成。但是注销无法解决这个问题。没有从手机中的浏览器注销我无法从我的应用程序注销。为什么会发生这种情况?我们如何避免这种情况

4

1 回答 1

0

There are two independent things going on here:
1) whether your user has authenticated your app (with permissions) to Facebook and
2) whether your user is logged in to Facebook.

Authentication is required the first time your user uses your app and lasts until the user explicitly de-authenticates (e.g. through the Facebook web Account Settings -> Apps -> App Settings).

Log in may be required each time your user starts your app. But if you use the default SDK authorize(), that tries to do a Single Sign On (SSO), where if the Facebook app is logged in, your app is automatically logged in and uses the existing access token.

If you are using SSO, when you do a logout, that has no effect, as a real logout would have to log out the Facebook app - which the user might not like!

You can get around this behavior by doing an authorize of the form

authorize(this, PERMISSIONS, FORCE_DIALOG_AUTH, new LoginDialogListener());

which avoids SSO and forces a dialog login. Of course, that then forces your user to login each time you start your app - unless you save the login details / access token under the covers (which is what the SDK does - check the source).

EDITED:

 m_facebook.authorize(FacebookActivity.this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH,
            new LoginDialogListener());

 class LoginDialogListener implements DialogListener
{
    public void onComplete(Bundle p_values)
    {
        saveCredentials(m_facebook);
        if (m_messageToPost != null)
        {
            postToWall(m_messageToPost);
        }
    }       
    public void onFacebookError(FacebookError p_error)
    {
        finish();
    }       
    public void onError(DialogError p_error)
    {
        finish();
    }       
    public void onCancel()
    {
        finish();
    }
}
于 2013-02-02T07:05:34.213 回答