(android)如何检查Facebook应用程序中的帐户是否更改然后继续注销

时间:2015-10-18 12:09:40

标签: android facebook facebook-graph-api facebook-sdk-4.0

我的目标是,在每个活动开始时,检查主Facebook应用程序中的Facebook帐户是否已更改,如果更改了强制继续

LoginManager.getInstance().logOut();

这里s my login code (i我没有使用会话):

LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            GraphRequest request = GraphRequest.newMeRequest(
                    loginResult.getAccessToken(),
                    new GraphRequest.GraphJSONObjectCallback() {
                        @Override
                        public void onCompleted(
                                JSONObject object,
                                GraphResponse response) {
                            try {
                                SharedPreferences set = getSharedPreferences("account_pref", 0);
                                SharedPreferences.Editor editor = set.edit();
                                editor.putString("fb_logged", "true");
                                editor.putString("fb_user", object.getString("name"));
                                editor.commit();
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }
                    });
            Bundle parameters = new Bundle();
            parameters.putString("fields", "id,name");
            request.setParameters(parameters);
            request.executeAsync();
        }

0 个答案:

没有答案