Java Code Examples for com.facebook.Session#closeAndClearTokenInformation()

The following examples show how to use com.facebook.Session#closeAndClearTokenInformation() . 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: LoginActivity.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    IAnalyticsMonitor monitor = BaseViewModel.getInstance().getMonitor();
    if (monitor != null) {
        monitor.stop();
    }
    Session activeSession = Session.getActiveSession();
    if (activeSession != null) {
        activeSession.closeAndClearTokenInformation();
    }
}
 
Example 2
Source File: FacebookFragment.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Closes the current session as well as clearing the token cache.
 */
protected final void closeSessionAndClearTokenInformation() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.closeAndClearTokenInformation();
        }
    }
}
 
Example 3
Source File: FacebookFragment.java    From Klyph with MIT License 5 votes vote down vote up
/**
 * Closes the current session as well as clearing the token cache.
 */
protected final void closeSessionAndClearTokenInformation() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.closeAndClearTokenInformation();
        }
    }
}
 
Example 4
Source File: FragmentSocialTimeline.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
public void loginError() {
    Session session = Session.getActiveSession();

    if (session != null && session.isOpened()) {
        session.closeAndClearTokenInformation();
    }
    loginMode = false;
    init();
}
 
Example 5
Source File: FacebookFragment.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
/**
 * Closes the current session as well as clearing the token cache.
 */
protected final void closeSessionAndClearTokenInformation() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.closeAndClearTokenInformation();
        }
    }
}
 
Example 6
Source File: FacebookFragment.java    From android-skeleton-project with MIT License 5 votes vote down vote up
/**
 * Closes the current session as well as clearing the token cache.
 */
protected final void closeSessionAndClearTokenInformation() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.closeAndClearTokenInformation();
        }
    }
}
 
Example 7
Source File: FacebookFragment.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
/**
 * Closes the current session as well as clearing the token cache.
 */
protected final void closeSessionAndClearTokenInformation() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.closeAndClearTokenInformation();
        }
    }
}
 
Example 8
Source File: FacebookFragment.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Closes the current session as well as clearing the token cache.
 */
protected final void closeSessionAndClearTokenInformation() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.closeAndClearTokenInformation();
        }
    }
}
 
Example 9
Source File: FacebookFragment.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Closes the current session as well as clearing the token cache.
 */
protected final void closeSessionAndClearTokenInformation() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.closeAndClearTokenInformation();
        }
    }
}
 
Example 10
Source File: FacebookFragment.java    From KlyphMessenger with MIT License 5 votes vote down vote up
/**
 * Closes the current session as well as clearing the token cache.
 */
protected final void closeSessionAndClearTokenInformation() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.closeAndClearTokenInformation();
        }
    }
}
 
Example 11
Source File: FacebookFragment.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Closes the current session as well as clearing the token cache.
 */
protected final void closeSessionAndClearTokenInformation() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.closeAndClearTokenInformation();
        }
    }
}
 
Example 12
Source File: FacebookFragment.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
/**
 * Closes the current session as well as clearing the token cache.
 */
protected final void closeSessionAndClearTokenInformation() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.closeAndClearTokenInformation();
        }
    }
}
 
Example 13
Source File: FacebookFragment.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Closes the current session as well as clearing the token cache.
 */
protected final void closeSessionAndClearTokenInformation() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.closeAndClearTokenInformation();
        }
    }
}
 
Example 14
Source File: LoginUsingActivityActivity.java    From FacebookNewsfeedSample-Android with Apache License 2.0 4 votes vote down vote up
private void onClickLogout() {
    Session session = Session.getActiveSession();
    if (!session.isClosed()) {
        session.closeAndClearTokenInformation();
    }
}
 
Example 15
Source File: SessionLoginFragment.java    From FacebookNewsfeedSample-Android with Apache License 2.0 4 votes vote down vote up
private void onClickLogout() {
    Session session = Session.getActiveSession();
    if (!session.isClosed()) {
        session.closeAndClearTokenInformation();
    }
}
 
Example 16
Source File: LoginButton.java    From KlyphMessenger with MIT License 4 votes vote down vote up
@Override
public void onClick(View v) {
    Context context = getContext();
    final Session openSession = sessionTracker.getOpenSession();

    if (openSession != null) {
        // If the Session is currently open, it must mean we need to log out
        if (confirmLogout) {
            // Create a confirmation dialog
            String logout = getResources().getString(R.string.com_facebook_loginview_log_out_action);
            String cancel = getResources().getString(R.string.com_facebook_loginview_cancel_action);
            String message;
            if (user != null && user.getName() != null) {
                message = String.format(getResources().getString(R.string.com_facebook_loginview_logged_in_as), user.getName());
            } else {
                message = getResources().getString(R.string.com_facebook_loginview_logged_in_using_facebook);
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage(message)
                   .setCancelable(true)
                   .setPositiveButton(logout, new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int which) {
                           openSession.closeAndClearTokenInformation();
                       }
                   })
                   .setNegativeButton(cancel, null);
            builder.create().show();
        } else {
            openSession.closeAndClearTokenInformation();
        }
    } else {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            sessionTracker.setSession(null);
            Session session = new Session.Builder(context).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = null;
            if (parentFragment != null) {
                openRequest = new Session.OpenRequest(parentFragment);
            } else if (context instanceof Activity) {
                openRequest = new Session.OpenRequest((Activity)context);
            }

            if (openRequest != null) {
                openRequest.setDefaultAudience(properties.defaultAudience);
                openRequest.setPermissions(properties.permissions);
                openRequest.setLoginBehavior(properties.loginBehavior);

                if (SessionAuthorizationType.PUBLISH.equals(properties.authorizationType)) {
                    currentSession.openForPublish(openRequest);
                } else {
                    currentSession.openForRead(openRequest);
                }
            }
        }
    }

    AppEventsLogger logger = AppEventsLogger.newLogger(getContext());

    Bundle parameters = new Bundle();
    parameters.putInt("logging_in", (openSession != null) ? 0 : 1);

    logger.logSdkEvent(loginLogoutEventName, null, parameters);
}
 
Example 17
Source File: SnakeGameActivity.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 4 votes vote down vote up
private void logoutAndUnlink() {
	
	//logout/unlink and wipe local dataset
	//new CognitoUnlinkTask().execute();	

	Session session = Session.openActiveSessionFromCache(SnakeGameActivity.this);
       if (session != null) {
           session.closeAndClearTokenInformation();
       }
       
       AmazonAuthorizationManager mAuthManager = new AmazonAuthorizationManager(this, Bundle.EMPTY);
       if (mAuthManager != null) {
           mAuthManager.clearAuthorizationState(null);
       }
       
       AWSClientManager.getCognitoSync().wipeData();


	Toast.makeText(gameView.getContext(), "Logout Successful",
			Toast.LENGTH_SHORT).show();
	
	
}
 
Example 18
Source File: LoginButton.java    From Klyph with MIT License 4 votes vote down vote up
@Override
public void onClick(View v) {
    Context context = getContext();
    final Session openSession = sessionTracker.getOpenSession();

    if (openSession != null) {
        // If the Session is currently open, it must mean we need to log out
        if (confirmLogout) {
            // Create a confirmation dialog
            String logout = getResources().getString(R.string.com_facebook_loginview_log_out_action);
            String cancel = getResources().getString(R.string.com_facebook_loginview_cancel_action);
            String message;
            if (user != null && user.getName() != null) {
                message = String.format(getResources().getString(R.string.com_facebook_loginview_logged_in_as), user.getName());
            } else {
                message = getResources().getString(R.string.com_facebook_loginview_logged_in_using_facebook);
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage(message)
                   .setCancelable(true)
                   .setPositiveButton(logout, new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int which) {
                           openSession.closeAndClearTokenInformation();
                       }
                   })
                   .setNegativeButton(cancel, null);
            builder.create().show();
        } else {
            openSession.closeAndClearTokenInformation();
        }
    } else {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            sessionTracker.setSession(null);
            Session session = new Session.Builder(context).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = null;
            if (parentFragment != null) {
                openRequest = new Session.OpenRequest(parentFragment);
            } else if (context instanceof Activity) {
                openRequest = new Session.OpenRequest((Activity)context);
            }

            if (openRequest != null) {
                openRequest.setDefaultAudience(properties.defaultAudience);
                openRequest.setPermissions(properties.permissions);
                openRequest.setLoginBehavior(properties.loginBehavior);

                if (SessionAuthorizationType.PUBLISH.equals(properties.authorizationType)) {
                    currentSession.openForPublish(openRequest);
                } else {
                    currentSession.openForRead(openRequest);
                }
            }
        }
    }

    AppEventsLogger logger = AppEventsLogger.newLogger(getContext());

    Bundle parameters = new Bundle();
    parameters.putInt("logging_in", (openSession != null) ? 0 : 1);

    logger.logSdkEvent(loginLogoutEventName, null, parameters);
}