/**
* Closes the current session.
*/
protected final void closeSession() {
if (sessionTracker != null) {
Session currentSession = sessionTracker.getOpenSession();
if (currentSession != null) {
currentSession.close();
}
}
}
java类com.facebook.Session的实例源码
FacebookFragment.java 文件源码
项目:AndroidBackendlessChat
阅读 22
收藏 0
点赞 0
评论 0
FacebookFragment.java 文件源码
项目:AndroidBackendlessChat
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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();
}
}
}
FacebookFragment.java 文件源码
项目:AndroidBackendlessChat
阅读 24
收藏 0
点赞 0
评论 0
/**
* Gets the permissions associated with the current session or null if no session
* has been created.
*
* @return the permissions associated with the current session
*/
protected final List<String> getSessionPermissions() {
if (sessionTracker != null) {
Session currentSession = sessionTracker.getSession();
return (currentSession != null) ? currentSession.getPermissions() : null;
}
return null;
}
FriendPickerFragment.java 文件源码
项目:AndroidBackendlessChat
阅读 16
收藏 0
点赞 0
评论 0
@Override
Request getRequestForLoadData(Session session) {
if (adapter == null) {
throw new FacebookException("Can't issue requests until Fragment has been created.");
}
String userToFetch = (userId != null) ? userId : "me";
return createRequest(userToFetch, extraFields, session);
}
BFacebookManager.java 文件源码
项目:AndroidBackendlessChat
阅读 19
收藏 0
点赞 0
评论 0
/** Re authenticate after session state changed.*/
public static Promise<Object, BError, Void> onSessionStateChange(Session session, SessionState state, Exception exception) {
if (DEBUG) Timber.i("Session changed state");
// If we can start the login process with no errors this promise wont be used.
// The returned promise will be from the loginWithFacebook.
Deferred<Object, BError, Void> deferred = new DeferredObject<>();
if (exception != null)
{
exception.printStackTrace();
if (exception instanceof FacebookOperationCanceledException)
{
deferred.reject(new BError(BError.Code.EXCEPTION, exception));
return deferred.promise();
}
}
if (state.isOpened()) {
if (DEBUG) Timber.i("Session is open.");
// We will need this session later to make request.
userFacebookAccessToken = Session.getActiveSession().getAccessToken();
return loginWithFacebook();
} else if (state.isClosed()) {
// Logged out of Facebook
if (DEBUG) Timber.i("Session is closed.");
deferred.reject(new BError(BError.Code.SESSION_CLOSED, "Facebook session is closed."));
}
return deferred.promise();
}
BFacebookManager.java 文件源码
项目:AndroidBackendlessChat
阅读 19
收藏 0
点赞 0
评论 0
public static Promise<GraphObject, BError, Void> getUserDetails(){
final Deferred<GraphObject, BError, Void> deferred = new DeferredObject<>();
if (Session.getActiveSession().getState().isOpened())
{
// Request user data and show the results
Request.newMeRequest(Session.getActiveSession(), new Request.GraphUserCallback()
{
@Override
public void onCompleted(GraphUser user, Response response)
{
if (response != null)
{
try
{
deferred.resolve(user);
}
catch (Exception e)
{
deferred.reject(BError.getExceptionError(e));
}
}
}
}).executeAsync();
} else deferred.reject(new BError(BError.Code.SESSION_CLOSED));
return deferred.promise();
}
ChatSDKBaseActivity.java 文件源码
项目:AndroidBackendlessChat
阅读 16
收藏 0
点赞 0
评论 0
protected void onSessionStateChange(Session session, final SessionState state, Exception exception){
BFacebookManager.onSessionStateChange(session, state, exception)
.fail(new FailCallback<BError>() {
@Override
public void onFail(BError bError) {
if (DEBUG) Timber.e("onDoneWithError. Error: %s", bError.message);
// Facebook session is closed so we need to disconnect from firebase.
getNetworkAdapter().logout();
startLoginActivity(true);
}
});
}
ChatSDKAbstractLoginActivity.java 文件源码
项目:AndroidBackendlessChat
阅读 18
收藏 0
点赞 0
评论 0
public void onSessionStateChange(Session session, SessionState state, Exception exception){
if (!getNetworkAdapter().facebookEnabled())
{
return;
}
if (exception != null)
{
exception.printStackTrace();
if (exception instanceof FacebookOperationCanceledException)
{
return;
}
}else showOrUpdateProgDialog(getString(R.string.authenticating));
BFacebookManager.onSessionStateChange(session, state, exception).done(new DoneCallback<Object>() {
@Override
public void onDone(Object o) {
if (DEBUG) Timber.i("Connected to facebook");
afterLogin();
}
}).fail(new FailCallback<BError>() {
@Override
public void onFail(BError bError) {
if (DEBUG) Timber.i(TAG, "Error connecting to Facebook");
// Toast.makeText(LoginActivity.this, "Failed connect to facebook.", Toast.LENGTH_SHORT).show();
showAlertToast( getString(R.string.login_activity_facebook_connection_fail_toast) );
BFacebookManager.logout(ChatSDKAbstractLoginActivity.this);
dismissProgDialog();
}
});
}
SessionTracker.java 文件源码
项目:chat-sdk-android-push-firebase
阅读 23
收藏 0
点赞 0
评论 0
/**
* Constructs a SessionTracker to track the Session object passed in.
* If the Session is null, then it will track the active Session instead.
*
* @param context the context object.
* @param callback the callback to use whenever the Session's state changes
* @param session the Session object to track
* @param startTracking whether to start tracking the Session right away
*/
public SessionTracker(Context context, Session.StatusCallback callback, Session session, boolean startTracking) {
this.callback = new CallbackWrapper(callback);
this.session = session;
this.receiver = new ActiveSessionBroadcastReceiver();
this.broadcastManager = LocalBroadcastManager.getInstance(context);
if (startTracking) {
startTracking();
}
}
SessionTracker.java 文件源码
项目:chat-sdk-android-push-firebase
阅读 24
收藏 0
点赞 0
评论 0
/**
* Returns the current Session that's being tracked if it's open,
* otherwise returns null.
*
* @return the current Session if it's open, otherwise returns null
*/
public Session getOpenSession() {
Session openSession = getSession();
if (openSession != null && openSession.isOpened()) {
return openSession;
}
return null;
}