book的SDK请求权限一次又一次像在Android上运行的循环

book的SDK请求权限一次又一次像在Android上运行的循环

本文介绍了Facebook的SDK请求权限一次又一次像在Android上运行的循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序使用Facebook的SDK(最新版本)。我只是想从登录的用户,如姓名,出生日期,地点,性别等的日起一般的数据,只是想填写相应的细节。但问题是,它显示了许可连连对话框无限连我preSS确定或取消该应用程序的权限对话框它做同样表明许可连连对话框。我无法理解什么错。

I am using Facebook SDK(latest version) in my app. I just want to take general data from the logged in user like name, date of birth, location, gender etc. and just want to fill the details accordingly. But the problem is that its showing the permission dialog again and again infinitely even I press Ok or Cancel for the app permission dialog its doing the same showing that permission dialog again and again. I cant understand whats wrong with this.

我的登录功能是这样的: -

my login function is like this :-

    Session.openActiveSession(context, true, new Session.StatusCallback() {

        @Override
        public void call(final Session session, SessionState state, Exception exception) {
            // TODO Auto-generated method stub
            if(session.isOpened())
            {
                Toast.makeText(context, "Please Wait", 1).show();
                List<String> permissions = session.getPermissions();

                if (!isSubsetOf(PERMISSIONS, permissions)) {
                    pendingPublishReauthorization = true;
                    Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(context, PERMISSIONS);
                    session.requestNewPublishPermissions(newPermissionsRequest);
                }

                Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

                    @Override
                    public void onCompleted(GraphUser user, Response response) {
                        // TODO Auto-generated method stub
                        if(user!=null)
                        {

                            try{
                                Log.d("", "Fb responcse == "+response.toString());
                                Log.d("", "FbUser >> "+ user.toString());
                                fbUserid=user.getId();
                                fbAccessToken=session.getAccessToken();
                                Log.i("User Name ", "FbName : "+user.getName());
                                Log.i("User Id ", "FbId : "+user.getId());
                                Log.i("User Id ", "FbLocation : "+user.getLocation().toString());

                                Log.i("User Id ", "FbEmailId : "+user.getLink());
                                Log.i("User Id ", "FbDob : "+user.getBirthday());

                                Log.i("User Id ", "FbGender : "+user.asMap().get("gender").toString());
                                Log.i("User Id ", "FbEmail : "+user.getProperty("email").toString());
                                //Log.i("User Id ", "FbCity : "+user.getLocation().getCity().toString());
                                //Log.i("User Id ", "FbState : "+user.getLocation().getState().toString());
                                Log.i("User Access Token ", "FbAccess Token : "+session.getAccessToken());
                                pBar.setVisibility(View.INVISIBLE);

                                String name = user.getName();
                                String dob = user.getBirthday();
                                String gender = user.asMap().get("gender").toString();
                                String email =user.getProperty("email").toString();
                                String city = user.getLocation().getProperty("name").toString();
                                String url="http://graph.facebook.com/"+user.getId()+"/picture?type=large";
                                setText(name, dob, email, city, "","",url);
                            }catch(Exception ex){
                                ex.printStackTrace();
                            }


                        }

                        else{
                            pBar.setVisibility(View.INVISIBLE);
                            Log.i("ELSE", "ELSE");
                        }
                    }


                });

            }


        }


    });

我也是使用许可使用该code片段来获得这些信息: -

Also I am using permission to get these details using this code snippet :-

List<String> PERMISSIONS = Arrays.asList("publish_actions","email","user_birthday","user_location");

请帮我理清这一点,因为它是一次又一次向我展示的唯一的权限对话框。

Please help me to sort out this, as it is again and again showing me the permission dialog only.

任何帮助将是AP preciable提前感谢

Any help would be appreciable thanks in advance

推荐答案

试试这个:

Session.openActiveSession(this, true, new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            if (session.isOpened())
            {
                List<String> PERMISSIONS = Arrays.asList("publish_actions");

                if (!session.getPermissions().containsAll(PERMISSIONS))
                {
                    Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(ActivityRegistration.this, PERMISSIONS);
                    session.requestNewPublishPermissions(newPermissionsRequest);
                }

                Request.newMeRequest(session, new Request.GraphUserCallback() {
                    @Override
                    public void onCompleted(GraphUser user, Response response) {
                        if (user != null) {
                            Log.i("Facebook Welcome " + user.getName());
                            compileWithFacebookInfo(user);
                        }
                    }
                }).executeAsync();
            }
        }
    });

我觉得这个问题是邮件,user_birthday,USER_LOCATION:是
    session.requestNewReadPermissions(...);

I think that issue is "email", "user_birthday", "user_location" : are session.requestNewReadPermissions(...);

这篇关于Facebook的SDK请求权限一次又一次像在Android上运行的循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 09:30