Here is my code for getting user information after facebook login. I am trying to get emailid from user I am getting Name , id , but not getting the emailid .I have tried with t
this way to get all part of Facebook login...
locationMangaer = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
loginButton = (LoginButton)findViewById(R.id.login_button);
loginButton.setReadPermissions(Arrays.asList("email", "user_photos", "public_profile", "user_friends"));
callbackManager= CallbackManager.Factory.create();
loginButton.registerCallback(callbackManager, new FacebookCallback() {
@Override
public void onSuccess(LoginResult loginResult) {
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Application code
Log.e("LoginActivity", response.toString() + " " + object.toString());
try {
String name=object.getString("name");
String email=object.getString("email");
String id=object.getString("id");
String gender=object.getString("gender");
Log.e("LoginActivity", name + " " + email + " " + id + " " + gender);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender, birthday");
request.setParameters(parameters);
request.executeAsync();
}
@Override
public void onCancel() {
// App code
Log.e("LOGIN Cancle", "LOGIN Cancle");
}
@Override
public void onError(FacebookException exception) {
// App code
Log.e("LOGIN Cancle", exception.getMessage());
}
});