com.facebook.SessionLoginBehavior Java Examples

The following examples show how to use com.facebook.SessionLoginBehavior. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FacebookFragment.java    From android-skeleton-project with MIT License 6 votes vote down vote up
private void openSession(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = new Session.OpenRequest(this).
                    setPermissions(permissions).
                    setLoginBehavior(behavior).
                    setRequestCode(activityCode);
            if (SessionAuthorizationType.PUBLISH.equals(authType)) {
                currentSession.openForPublish(openRequest);
            } else {
                currentSession.openForRead(openRequest);
            }
        }
    }
}
 
Example #2
Source File: FacebookFragment.java    From FacebookNewsfeedSample-Android with Apache License 2.0 6 votes vote down vote up
private void openSession(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = new Session.OpenRequest(this).
                    setPermissions(permissions).
                    setLoginBehavior(behavior).
                    setRequestCode(activityCode);
            if (SessionAuthorizationType.PUBLISH.equals(authType)) {
                currentSession.openForPublish(openRequest);
            } else {
                currentSession.openForRead(openRequest);
            }
        }
    }
}
 
Example #3
Source File: FacebookFragment.java    From KlyphMessenger with MIT License 6 votes vote down vote up
private void openSession(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = new Session.OpenRequest(this).
                    setPermissions(permissions).
                    setLoginBehavior(behavior).
                    setRequestCode(activityCode);
            if (SessionAuthorizationType.PUBLISH.equals(authType)) {
                currentSession.openForPublish(openRequest);
            } else {
                currentSession.openForRead(openRequest);
            }
        }
    }
}
 
Example #4
Source File: FacebookFragment.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void openSession(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = new Session.OpenRequest(this).
                    setPermissions(permissions).
                    setLoginBehavior(behavior).
                    setRequestCode(activityCode);
            if (SessionAuthorizationType.PUBLISH.equals(authType)) {
                currentSession.openForPublish(openRequest);
            } else {
                currentSession.openForRead(openRequest);
            }
        }
    }
}
 
Example #5
Source File: FacebookFragment.java    From Abelana-Android with Apache License 2.0 6 votes vote down vote up
private void openSession(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = new Session.OpenRequest(this).
                    setPermissions(permissions).
                    setLoginBehavior(behavior).
                    setRequestCode(activityCode);
            if (SessionAuthorizationType.PUBLISH.equals(authType)) {
                currentSession.openForPublish(openRequest);
            } else {
                currentSession.openForRead(openRequest);
            }
        }
    }
}
 
Example #6
Source File: FacebookFragment.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 6 votes vote down vote up
private void openSession(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = new Session.OpenRequest(this).
                    setPermissions(permissions).
                    setLoginBehavior(behavior).
                    setRequestCode(activityCode);
            if (SessionAuthorizationType.PUBLISH.equals(authType)) {
                currentSession.openForPublish(openRequest);
            } else {
                currentSession.openForRead(openRequest);
            }
        }
    }
}
 
Example #7
Source File: FacebookFragment.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
private void openSession(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = new Session.OpenRequest(this).
                    setPermissions(permissions).
                    setLoginBehavior(behavior).
                    setRequestCode(activityCode);
            if (SessionAuthorizationType.PUBLISH.equals(authType)) {
                currentSession.openForPublish(openRequest);
            } else {
                currentSession.openForRead(openRequest);
            }
        }
    }
}
 
Example #8
Source File: FacebookFragment.java    From HypFacebook with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void openSession(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = new Session.OpenRequest(this).
                    setPermissions(permissions).
                    setLoginBehavior(behavior).
                    setRequestCode(activityCode);
            if (SessionAuthorizationType.PUBLISH.equals(authType)) {
                currentSession.openForPublish(openRequest);
            } else {
                currentSession.openForRead(openRequest);
            }
        }
    }
}
 
Example #9
Source File: FacebookFragment.java    From Klyph with MIT License 6 votes vote down vote up
private void openSession(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = new Session.OpenRequest(this).
                    setPermissions(permissions).
                    setLoginBehavior(behavior).
                    setRequestCode(activityCode);
            if (SessionAuthorizationType.PUBLISH.equals(authType)) {
                currentSession.openForPublish(openRequest);
            } else {
                currentSession.openForRead(openRequest);
            }
        }
    }
}
 
Example #10
Source File: FacebookFragment.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
private void openSession(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = new Session.OpenRequest(this).
                    setPermissions(permissions).
                    setLoginBehavior(behavior).
                    setRequestCode(activityCode);
            if (SessionAuthorizationType.PUBLISH.equals(authType)) {
                currentSession.openForPublish(openRequest);
            } else {
                currentSession.openForRead(openRequest);
            }
        }
    }
}
 
Example #11
Source File: FacebookFragment.java    From facebook-api-android-maven with Apache License 2.0 6 votes vote down vote up
private void openSession(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = new Session.OpenRequest(this).
                    setPermissions(permissions).
                    setLoginBehavior(behavior).
                    setRequestCode(activityCode);
            if (SessionAuthorizationType.PUBLISH.equals(authType)) {
                currentSession.openForPublish(openRequest);
            } else {
                currentSession.openForRead(openRequest);
            }
        }
    }
}
 
Example #12
Source File: SettingsFragment.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
void restore(Context context, int oldSelectedSlot) {
    if (context == null) {
        throw new IllegalArgumentException("context cannot be null");
    }

    Context applicationContext = context.getApplicationContext();
    applicationContext = (applicationContext == null) ? context : applicationContext;

    slots = new Slot[MAX_SLOTS];
    for (int i = 0; i < MAX_SLOTS; i++) {
        SessionLoginBehavior loginBehavior = (i == 0) ?
                SessionLoginBehavior.SSO_WITH_FALLBACK :
                SessionLoginBehavior.SUPPRESS_SSO;
        slots[i] = new Slot(applicationContext, i, loginBehavior);
    }

    // Restore the last known state from when the app ran last.
    settings = applicationContext.getSharedPreferences(SETTINGS_NAME, Context.MODE_PRIVATE);
    int savedSlotNumber = settings.getInt(SETTINGS_CURRENT_SLOT_KEY, NO_SLOT);
    if (savedSlotNumber != NO_SLOT && savedSlotNumber != oldSelectedSlot) {
        // This will trigger the full flow of creating and opening the right session
        toggleSlot(savedSlotNumber);
    } else {
        // We already knew which slot was selected. So don't notify that a new slot was
        // selected since that will close out the old session and recreate a new one. And
        // doing so will have the effect of clearing out state like the profile pic.
        setSelectedSlotNumber(savedSlotNumber);
    }
}
 
Example #13
Source File: UserSettingsFragmentTests.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@MediumTest
@LargeTest
public void testCanSetParametersViaLayout() throws Throwable {
    TestActivity activity = getActivity();
    assertNotNull(activity);

    final UserSettingsFragment fragment = activity.getFragment();
    assertNotNull(fragment);

    assertEquals(SessionLoginBehavior.SUPPRESS_SSO, fragment.getLoginBehavior());
    assertEquals(SessionDefaultAudience.EVERYONE, fragment.getDefaultAudience());
    List<String> permissions = fragment.getPermissions();
    assertEquals(2, permissions.size());
    assertEquals("read_1", permissions.get(0));
}
 
Example #14
Source File: UserSettingsFragmentTests.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportFragmentManager().executePendingTransactions();
    UserSettingsFragment fragment = getFragment();
    fragment.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);
    fragment.setReadPermissions("read_1", "read_2");
    fragment.setDefaultAudience(SessionDefaultAudience.EVERYONE);
}
 
Example #15
Source File: LoginButton.java    From Klyph with MIT License 4 votes vote down vote up
public SessionLoginBehavior getLoginBehavior() {
    return loginBehavior;
}
 
Example #16
Source File: LoginButton.java    From Klyph with MIT License 4 votes vote down vote up
public void setLoginBehavior(SessionLoginBehavior loginBehavior) {
    this.loginBehavior = loginBehavior;
}
 
Example #17
Source File: LoginButton.java    From KlyphMessenger with MIT License 4 votes vote down vote up
public void setLoginBehavior(SessionLoginBehavior loginBehavior) {
    this.loginBehavior = loginBehavior;
}
 
Example #18
Source File: LoginButton.java    From KlyphMessenger with MIT License 4 votes vote down vote up
public SessionLoginBehavior getLoginBehavior() {
    return loginBehavior;
}
 
Example #19
Source File: FacebookFragment.java    From KlyphMessenger with MIT License 2 votes vote down vote up
/**
 * Opens a new session with publish permissions. If either applicationID is null,
 * this method will default to using the value from the associated
 * meta-data value. The permissions list cannot be null.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, cannot be null
 * @param behavior the login behavior to use with the session
 * @param activityCode the activity code to use for the SSO activity
 */
protected final void openSessionForPublish(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode) {
    openSession(applicationId, permissions, behavior, activityCode, SessionAuthorizationType.PUBLISH);
}
 
Example #20
Source File: FacebookFragment.java    From KlyphMessenger with MIT License 2 votes vote down vote up
/**
 * Opens a new session with publish permissions. If either applicationID is null,
 * this method will default to using the value from the associated
 * meta-data value. The permissions list cannot be null.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, cannot be null
 */
protected final void openSessionForPublish(String applicationId, List<String> permissions) {
    openSessionForPublish(applicationId, permissions, SessionLoginBehavior.SSO_WITH_FALLBACK,
            Session.DEFAULT_AUTHORIZE_ACTIVITY_CODE);
}
 
Example #21
Source File: FacebookFragment.java    From KlyphMessenger with MIT License 2 votes vote down vote up
/**
 * Opens a new session with read permissions. If either applicationID or permissions
 * is null, this method will default to using the values from the associated
 * meta-data value and an empty list respectively.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, can be null
 * @param behavior the login behavior to use with the session
 * @param activityCode the activity code to use for the SSO activity
 */
protected final void openSessionForRead(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode) {
    openSession(applicationId, permissions, behavior, activityCode, SessionAuthorizationType.READ);
}
 
Example #22
Source File: FacebookFragment.java    From KlyphMessenger with MIT License 2 votes vote down vote up
/**
 * Opens a new session with read permissions. If either applicationID or permissions
 * is null, this method will default to using the values from the associated
 * meta-data value and an empty list respectively.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, can be null
 */
protected final void openSessionForRead(String applicationId, List<String> permissions) {
    openSessionForRead(applicationId, permissions, SessionLoginBehavior.SSO_WITH_FALLBACK,
            Session.DEFAULT_AUTHORIZE_ACTIVITY_CODE);
}
 
Example #23
Source File: FacebookFragment.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 2 votes vote down vote up
/**
 * Opens a new session with publish permissions. If either applicationID is null,
 * this method will default to using the value from the associated
 * meta-data value. The permissions list cannot be null.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, cannot be null
 */
protected final void openSessionForPublish(String applicationId, List<String> permissions) {
    openSessionForPublish(applicationId, permissions, SessionLoginBehavior.SSO_WITH_FALLBACK,
            Session.DEFAULT_AUTHORIZE_ACTIVITY_CODE);
}
 
Example #24
Source File: FacebookFragment.java    From Abelana-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Opens a new session with publish permissions. If either applicationID is null,
 * this method will default to using the value from the associated
 * meta-data value. The permissions list cannot be null.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, cannot be null
 * @param behavior the login behavior to use with the session
 * @param activityCode the activity code to use for the SSO activity
 */
protected final void openSessionForPublish(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode) {
    openSession(applicationId, permissions, behavior, activityCode, SessionAuthorizationType.PUBLISH);
}
 
Example #25
Source File: FacebookFragment.java    From FacebookNewsfeedSample-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Opens a new session with read permissions. If either applicationID or permissions
 * is null, this method will default to using the values from the associated
 * meta-data value and an empty list respectively.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, can be null
 * @param behavior the login behavior to use with the session
 * @param activityCode the activity code to use for the SSO activity
 */
protected final void openSessionForRead(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode) {
    openSession(applicationId, permissions, behavior, activityCode, SessionAuthorizationType.READ);
}
 
Example #26
Source File: FacebookFragment.java    From HypFacebook with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Opens a new session with publish permissions. If either applicationID is null,
 * this method will default to using the value from the associated
 * meta-data value. The permissions list cannot be null.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, cannot be null
 */
protected final void openSessionForPublish(String applicationId, List<String> permissions) {
    openSessionForPublish(applicationId, permissions, SessionLoginBehavior.SSO_WITH_FALLBACK,
            Session.DEFAULT_AUTHORIZE_ACTIVITY_CODE);
}
 
Example #27
Source File: FacebookFragment.java    From HypFacebook with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Opens a new session with publish permissions. If either applicationID is null,
 * this method will default to using the value from the associated
 * meta-data value. The permissions list cannot be null.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, cannot be null
 * @param behavior the login behavior to use with the session
 * @param activityCode the activity code to use for the SSO activity
 */
protected final void openSessionForPublish(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode) {
    openSession(applicationId, permissions, behavior, activityCode, SessionAuthorizationType.PUBLISH);
}
 
Example #28
Source File: FacebookFragment.java    From FacebookNewsfeedSample-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Opens a new session with read permissions. If either applicationID or permissions
 * is null, this method will default to using the values from the associated
 * meta-data value and an empty list respectively.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, can be null
 */
protected final void openSessionForRead(String applicationId, List<String> permissions) {
    openSessionForRead(applicationId, permissions, SessionLoginBehavior.SSO_WITH_FALLBACK,
            Session.DEFAULT_AUTHORIZE_ACTIVITY_CODE);
}
 
Example #29
Source File: FacebookFragment.java    From HypFacebook with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Opens a new session with read permissions. If either applicationID or permissions
 * is null, this method will default to using the values from the associated
 * meta-data value and an empty list respectively.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, can be null
 * @param behavior the login behavior to use with the session
 * @param activityCode the activity code to use for the SSO activity
 */
protected final void openSessionForRead(String applicationId, List<String> permissions,
        SessionLoginBehavior behavior, int activityCode) {
    openSession(applicationId, permissions, behavior, activityCode, SessionAuthorizationType.READ);
}
 
Example #30
Source File: FacebookFragment.java    From FacebookNewsfeedSample-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Opens a new session with publish permissions. If either applicationID is null,
 * this method will default to using the value from the associated
 * meta-data value. The permissions list cannot be null.
 *
 * @param applicationId the applicationID, can be null
 * @param permissions the permissions list, cannot be null
 */
protected final void openSessionForPublish(String applicationId, List<String> permissions) {
    openSessionForPublish(applicationId, permissions, SessionLoginBehavior.SSO_WITH_FALLBACK,
            Session.DEFAULT_AUTHORIZE_ACTIVITY_CODE);
}