当前位置: 首页>>代码示例>>Java>>正文


Java Session.close方法代码示例

本文整理汇总了Java中com.facebook.Session.close方法的典型用法代码示例。如果您正苦于以下问题:Java Session.close方法的具体用法?Java Session.close怎么用?Java Session.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.Session的用法示例。


在下文中一共展示了Session.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: closeSession

import com.facebook.Session; //导入方法依赖的package包/类
/**
 * Closes the current session.
 */
protected final void closeSession() {
    if (sessionTracker != null) {
        Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            currentSession.close();
        }
    }
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:12,代码来源:FacebookFragment.java

示例2: getSession

import com.facebook.Session; //导入方法依赖的package包/类
/**
 * Get the underlying Session object to use with 3.0 api.
 * 
 * @return Session - underlying session
 */
@Deprecated
public final Session getSession() {
    while (true) {
        String cachedToken = null;
        Session oldSession = null;

        synchronized (this.lock) {
            if (userSetSession != null) {
                return userSetSession;
            }
            if ((session != null) || !sessionInvalidated) {
                return session;
            }

            cachedToken = accessToken;
            oldSession = session;
        }

        if (cachedToken == null) {
            return null;
        }

        // At this point we do not have a valid session, but mAccessToken is
        // non-null.
        // So we can try building a session based on that.
        List<String> permissions;
        if (oldSession != null) {
            permissions = oldSession.getPermissions();
        } else if (pendingAuthorizationPermissions != null) {
            permissions = Arrays.asList(pendingAuthorizationPermissions);
        } else {
            permissions = Collections.<String>emptyList();
        }

        Session newSession = new Session.Builder(pendingAuthorizationActivity).
                setApplicationId(mAppId).
                setTokenCachingStrategy(getTokenCache()).
                build();
        if (newSession.getState() != SessionState.CREATED_TOKEN_LOADED) {
            return null;
        }
        Session.OpenRequest openRequest =
                new Session.OpenRequest(pendingAuthorizationActivity).setPermissions(permissions);
        openSession(newSession, openRequest, !permissions.isEmpty());

        Session invalidatedSession = null;
        Session returnSession = null;

        synchronized (this.lock) {
            if (sessionInvalidated || (session == null)) {
                invalidatedSession = session;
                returnSession = session = newSession;
                sessionInvalidated = false;
            }
        }

        if (invalidatedSession != null) {
            invalidatedSession.close();
        }

        if (returnSession != null) {
            return returnSession;
        }
        // Else token state changed between the synchronized blocks, so
        // retry..
    }
}
 
开发者ID:yeloapp,项目名称:yelo-android,代码行数:73,代码来源:Facebook.java

示例3: onActivityResult

import com.facebook.Session; //导入方法依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case USER_HOME_ACTIVITY:
            Session session = Session.getActiveSession();
            if (session != null) {
                session.close();
            }

            getSelectedFriendData();
            break;
        case FB_LOGIN_ACTIVITY:
            if (data == null || data.getExtras() == null
                    || data.getExtras().getString("userId") == null) {
                Toast.makeText(this, "something went wrong, try later...",
                        Toast.LENGTH_SHORT).show();
                finish();
                return;
            }
            String userId = data.getExtras().getString("userId");
            String userName = data.getExtras().getString("userName");

            if (userId == null) {
                Toast.makeText(this, "something went wrong, try later...",
                        Toast.LENGTH_SHORT).show();
                finish();
                return;
            }

            Session.getActiveSession().close();


            final ProgressDialog progressDialog = ProgressDialog.show(this, "Registering",
                    "Please wait...", true);

            CallService.getDefaultInstance().register(userId, userName, GOOGLE_CLOUD_PROJECT_ID, MainActivity.this, new CallService.Callback() {
                @Override
                public void onError(Exception error) {
                    error.printStackTrace();
                    progressDialog.dismiss();
                    Toast.makeText(MainActivity.this, "failed to register!", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onSuccess() {
                    progressDialog.dismiss();

                    startUserHomeActivity();
                }
            });

            break;
        case OUTGOING_CALL_ACTIVITY:
            startUserHomeActivity();
            break;
        default:
            super.onActivityResult(requestCode, resultCode, data);
            break;
    }
}
 
开发者ID:3bytessolutions,项目名称:CallService-Facebook-sample,代码行数:60,代码来源:MainActivity.java


注:本文中的com.facebook.Session.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。