use of com.facebook.Session in project openkit-android by OpenKit.
the class FacebookFragment method openSession.
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);
}
}
}
}
use of com.facebook.Session in project openkit-android by OpenKit.
the class SessionTracker method stopTracking.
/**
* Stop tracking the Session and remove any callbacks attached
* to those sessions.
*/
public void stopTracking() {
if (!isTracking) {
return;
}
Session session = getSession();
if (session != null) {
session.removeCallback(callback);
}
broadcastManager.unregisterReceiver(receiver);
isTracking = false;
}
use of com.facebook.Session in project phonegap-facebook-plugin by Wizcorp.
the class ConnectPlugin method onSessionStateChange.
/*
* Handles session state changes
*/
private void onSessionStateChange(SessionState state, Exception exception) {
Log.d(TAG, "onSessionStateChange:" + state.toString());
if (exception != null && exception instanceof FacebookOperationCanceledException) {
// only handle FacebookOperationCanceledException to support
// SDK recovery behavior triggered by getUserInfo
Log.e(TAG, "exception:" + exception.toString());
handleError(exception, loginContext);
} else {
final Session session = Session.getActiveSession();
// Check if the session is open
if (state.isOpened()) {
if (loginContext != null) {
// Get user info
getUserInfo(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
// Create a new result with response data
if (loginContext != null) {
if (response.getError() != null) {
loginContext.error(getFacebookRequestErrorResponse(response.getError()));
} else {
GraphObject graphObject = response.getGraphObject();
Log.d(TAG, "returning login object " + graphObject.getInnerJSONObject().toString());
userID = user.getId();
loginContext.success(getResponse());
loginContext = null;
}
} else {
// Just update the userID in case we force quit the application before
userID = user.getId();
}
}
});
} else if (graphContext != null) {
// Make the graph call
makeGraphCall();
}
} else if (state == SessionState.CLOSED_LOGIN_FAILED && loginContext != null) {
handleError(new FacebookAuthorizationException("Session was closed and was not closed normally"), loginContext);
}
}
}
use of com.facebook.Session in project phonegap-facebook-plugin by Wizcorp.
the class FacebookFragment method openSession.
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);
}
}
}
}
use of com.facebook.Session in project phonegap-facebook-plugin by Wizcorp.
the class SessionTracker method stopTracking.
/**
* Stop tracking the Session and remove any callbacks attached
* to those sessions.
*/
public void stopTracking() {
if (!isTracking) {
return;
}
Session session = getSession();
if (session != null) {
session.removeCallback(callback);
}
broadcastManager.unregisterReceiver(receiver);
isTracking = false;
}
Aggregations