什么是这块code的在做什么? [英] What is this piece of code doing?

查看:237
本文介绍了什么是这块code的在做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到这个从
https://developers.facebook.com/docs/android/login -with-的Facebook / V2.1

基本上它涉及到在登录过程。

Basically it relates to the login process

private void onClickLogin() {
    Session session = Session.getActiveSession();
    if (!session.isOpened() && !session.isClosed()) {
        session.openForRead(new Session.OpenRequest(this)
        .setPermissions(Arrays.asList("public_profile"))
        .setCallback(statusCallback));
    } else {
        Session.openActiveSession(getActivity(), this, true, statusCallback);
    }
}

为什么Facebook的检查,如果一个会话没有打开(关闭我假设)和未关闭会话(假设其开放的话)?

Why does facebook check if a session is not opened(closed i am assuming) and the session is not closed(assuming its open then)?

这会不会条件语句总是为false?

Won't this conditional statement always evaluate to false?

推荐答案

如果您检查<一个href=\"https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/SessionState.java\"相对=nofollow>来源,你会发现, isOpened()在isClosed()是不是彼此的逻辑互补而只是两个​​不同的状态枚举值会话可以在

If you examine the source, you'll notice that isOpened() and isClosed() are not logical complements of each other but just two distinct state enumeration values the session can be in.

这篇关于什么是这块code的在做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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