Facebook的API的方法:isSessionValid()总是返回true [英] Facebook API's method: isSessionValid() always returns true

查看:411
本文介绍了Facebook的API的方法:isSessionValid()总是返回true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用href=\"http://developers.facebook.com/docs/mobile/android/build/\" rel=\"nofollow\">官方Facebook SDK为Android 的

I am using the official facebook SDK for Android and I am facing some issues regarding session management. Specifically, I don't know how to test whether the session is still valid or not.

首先,我初始化和授权接驳至Facebook:

First I initialize and authorize a connexion to facebook:

Facebook facebook = new Facebook(context.getString(R.string.facebook_app_id));
facebook.authorize(...); // Works ok

然后,我要断开用户连接:

Then, I want to disconnect the user:

facebook.logout(context);

但是,一旦我这样做,下面的还是返回真正的:

facebook.isSessionValid();

为什么它返回的真正的?

什么我做错了吗?

谢谢!

推荐答案

也许你遇到一个老的bug。是你的Facebook SDK最新的吗?

Maybe you encountered an older bug. Is your Facebook SDK up to date?

据<一个href=\"https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/android/Facebook.java\"相对=nofollow>来源,注销电话 setAccessToken(NULL); 。如果令牌为空, isSessionValid()应该返回false。下面是它的code,以供参考:

According to the source, logout calls setAccessToken(null);. And if the token is null, isSessionValid() should return false. Here is it's code for reference:

public boolean isSessionValid() {
    return (getAccessToken() != null) &&
            ((getAccessExpires() == 0) ||
                    (System.currentTimeMillis() < getAccessExpires()));
}

本的getter / setter不做任何空支票要么,所以在注销()调用应该收到预期的效果。

The getter/setter doesn't do any null-checks either, so the call in logout() should have the desired effect.

这篇关于Facebook的API的方法:isSessionValid()总是返回true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆