1

First Button has the following perms , and after I'm writting the code as is described in the try catch to make the call to facebook and retrieving data, when click button is pressed. Here there no need to set parameters like another api call.

In the folowing link shows the implementation too, https://developers.facebook.com/docs/android/graph

    loginButtonFacebooK.setReadPermissions(Arrays
                .asList("public_profile"," email",  "user_friends"));


          try {
                        LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
                            @Override
                            public void onSuccess(LoginResult loginResult) {
                                accessToken = loginResult.getAccessToken();

                                if( accessToken != null ){

                                    GraphRequestBatch batch = new GraphRequestBatch(GraphRequest.newMeRequest(accessToken,
                                            new GraphRequest.GraphJSONObjectCallback() {

                                                @Override
                                                public void onCompleted(JSONObject object, GraphResponse response) {


                                                    try {
                                                        String versionApp = GeneralLogic.getVersionName( SplashActivity.this );
                                                        Usuario usuarioNexusDomun = new Usuario(
                                                                object.getString("id"),
                                                                object.getString("first_name"),
                                                                object.getString("last_name"),
                                                                object.getString("name"),
                                                                object.getString("link"),
                                                                object.getString("gender"),
                                                                object.getString("updated_time"),
                                                                token.getToken(),
                                                                versionApp);

                                    // here is saving data and just is showing id and name, 
                                    // other data is coming null

                                                    loginFacebookOk = true;
                                                    } catch (JSONException e) {
                                                            e.getMessage();
                                                    }



                                                }

                                            })

                                    );

                                    batch.addCallback(new GraphRequestBatch.Callback() {

                                        @Override
                                        public void onBatchCompleted(GraphRequestBatch batch) {

                                                     if( loginFacebookOk ) {

                                                         gotoMain();

                                                        } else {

                                                         errorMsg(1);

                                                        }
                                        }
                                    });



                                }


                            }

                            @Override
                            public void onCancel() {

                            }

                            @Override
                            public void onError(FacebookException error) {

                            }
                        });
                    }catch (Exception e){
                        e.getMessage();
                    }
RPR
  • 53
  • 9
  • 1
    this question has been asked at least a hundred times already. see for "declarative fields" in the changelog: https://developers.facebook.com/docs/apps/changelog#v2_4 – andyrandy Dec 22 '15 at 15:25
  • 1
    the example code on the page you linked to even includes code for declarative fields... – andyrandy Dec 22 '15 at 15:26
  • I know that exists declarative fields to send as parameters, but if you see, as i said, are different calls. in the link of the example. I am not using GraphRequest Class example, Im using Batch Requests example, and in this call , this call don't let you set the parameters, and doesn't have the method to do it. – RPR Dec 22 '15 at 15:54

0 Answers0