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();
}