private void startOpenSessionRequest ( final Activity activity , final Fragment fragment ) { // State transition. mLinkRequestState = STATE_OPEN_SESSION_REQUEST ; // Construct status callback. Session . StatusCallback statusCallback = new Session . StatusCallback ( ) { @ Override public void call ( Session session , SessionState state , Exception exception ) { if ( mLinkRequestState == STATE_OPEN_SESSION_REQUEST && state . isOpened ( ) ) { // Request publish permissions. if ( ! startPublishPermissionsRequest ( activity , fragment ) ) { handleLinkError ( ) ; } } } } ; // Construct new session. Session session = new Session ( activity ) ; Session . setActiveSession ( session ) ; // Construct read permissions to request for. List < String > readPermissions = new LinkedList < String > ( ) ; readPermissions . add ( PERMISSION_PUBLIC_PROFILE ) ; readPermissions . add ( PERMISSION_USER_PHOTOS ) ; // Construct open request. OpenRequest openRequest ; if ( fragment == null ) { openRequest = new OpenRequest ( activity ) ; } else { openRequest = new OpenRequest ( fragment ) ; } // Allow SSO login only because the web login does not allow PERMISSION_USER_PHOTOS to be bundled with the // first openForRead() call. openRequest . setLoginBehavior ( SessionLoginBehavior . SSO_ONLY ) ; openRequest . setPermissions ( readPermissions ) ; openRequest . setDefaultAudience ( SessionDefaultAudience . EVERYONE ) ; openRequest . setCallback ( statusCallback ) ; // Execute open request. session . openForRead ( openRequest ) ; }
Opens a new session with read permissions .