FacebookCallback#onCancel() is calling after login once in Facebook Sdk 4.2.0 in Android

余生长醉 提交于 2019-12-05 15:24:36
Rahul Rastogi

I solved this problem by calling: LoginManager.getInstance().logOut(); just before trying to login.

i have not tried the above mentioned code but the thing worked for me is i have written some code in on cancel same as in success

@Override
        public void onCancel() {
            AccessToken token = AccessToken.getCurrentAccessToken();
            if (token != null) {
                GraphRequest request = GraphRequest.newMeRequest(
                        token,
                        new GraphRequest.GraphJSONObjectCallback() {
                            @Override
                            public void onCompleted(
                                    JSONObject object,
                                    GraphResponse response) {
                                FBObject = response.getJSONObject();

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

            }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!