0

I got this from 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);
    }
}

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

Won't this conditional statement always evaluate to false?

DeanOC
  • 7,142
  • 6
  • 42
  • 56
committedandroider
  • 8,711
  • 14
  • 71
  • 126

1 Answers1

1

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.

laalto
  • 150,114
  • 66
  • 286
  • 303
  • Logic wise, wouldn't it make more sense to just check that the session " the state represents a successfully opened state in which the Session can be used with a {@link Request}"(docs you sent me) so you can set the correct permissions? – committedandroider Aug 19 '14 at 05:48