当我启动Facebook应用程序时,如何避免我的应用程序自动启动

时间:2016-04-21 08:33:04

标签: android facebook facebook-graph-api login logout

我创建了一个应用程序,用户可以通过Facebook登录按钮登录。问题是 - 每当我在手机上启动Facebook应用程序时,它也会自动启动其他应用程序并将用户登录。任何想法如何避免这种情况? 这是我对facebook的登录操作:

fbLoginButton.setReadPermissions("user_friends");

    // Callback registration

    fbLoginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {

        @Override
        public void onSuccess(LoginResult loginResult) {
            // App code
            Log.v("STATUS", loginResult.getAccessToken().toString());
            GraphRequest request = GraphRequest.newMeRequest(
                    loginResult.getAccessToken(),
                    new GraphRequest.GraphJSONObjectCallback() {
                        @Override
                        public void onCompleted(
                                JSONObject object,
                                GraphResponse response) {

                            Log.e("response: ", response + "");
                            try {
                                String facebookID = object.getString("id").toString();
                                String email = object.getString("email").toString();
                                String name = object.getString("name").toString();
                                //PrefUtils.setCurrentUser(user,LoginActivity.this);

                                String[] nameArray = name.split(" ");
                                String firstname = nameArray[0];
                                String lastname = nameArray[1];
                                Log.v("FIRSTNAME", firstname);

                                if(response.getError() == null) {
                                   new FBLogin().execute(email, firstname, lastname, facebookID);
                                }

                                Log.v("FBEMAIL", object.toString());
                            }catch (Exception e){
                                e.printStackTrace();
                            }
                        }

                    });
            Bundle parameters = new Bundle();
            parameters.putString("fields", "id,name,email,gender");
            request.setParameters(parameters);
            request.executeAsync();
        }

        @Override
        public void onCancel() {
            // App code
            Log.v("im in", "2");
        }

        @Override
        public void onError(FacebookException exception) {
            // App code
            Log.v("im in", "3");
        }
    });

// catches fb login callback
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    callbackManager.onActivityResult(requestCode, resultCode, data);
}

我是否必须使用我的注销按钮以特殊方式将用户注销?直到现在注销它只是重定向回我的主要活动,用户必须通过点击fb按钮手动注销。我感到困惑,谷歌无法帮助我......

0 个答案:

没有答案