Java Code Examples for com.facebook.Session#OpenRequest
The following examples show how to use
com.facebook.Session#OpenRequest .
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 platform-friends-android with BSD 2-Clause "Simplified" License | 6 votes |
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 Klyph with MIT License | 6 votes |
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 barterli_android with Apache License 2.0 | 6 votes |
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 android-skeleton-project with MIT License | 6 votes |
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 FacebookImageShareIntent with MIT License | 6 votes |
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 |
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 Abelana-Android with Apache License 2.0 | 6 votes |
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 KlyphMessenger with MIT License | 6 votes |
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 facebook-api-android-maven with Apache License 2.0 | 6 votes |
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 HypFacebook with BSD 2-Clause "Simplified" License | 6 votes |
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 FacebookNewsfeedSample-Android with Apache License 2.0 | 6 votes |
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: HypFacebookFrag.java From HypFacebook with BSD 2-Clause "Simplified" License | 5 votes |
/** * * * @private * @return void */ private void _authorize( ){ trace("_authorize"); final Session.OpenRequest req = new Session.OpenRequest( this ); req.setPermissions( _aPermissions ); Session.getActiveSession( ).openForRead( req ); }
Example 13
Source File: LoginButton.java From Klyph with MIT License | 4 votes |
@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 14
Source File: LoginButton.java From KlyphMessenger with MIT License | 4 votes |
@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); }