public void onResume ( ) { Session session = Session . getActiveSession ( ) ; if ( session != null ) { if ( callback != null ) { session . addCallback ( callback ) ; } if ( SessionState . CREATED_TOKEN_LOADED . equals ( session . getState ( ) ) ) { session . openForRead ( null ) ; } } // add the broadcast receiver IntentFilter filter = new IntentFilter ( ) ; filter . addAction ( Session . ACTION_ACTIVE_SESSION_SET ) ; filter . addAction ( Session . ACTION_ACTIVE_SESSION_UNSET ) ; // Add a broadcast receiver to listen to when the active Session // is set or unset, and add/remove our callback as appropriate broadcastManager . registerReceiver ( receiver , filter ) ; }
To be called from an Activity or Fragment s onResume method .