How to get Email ID from the Facebook SDK in Android Application?

private FacebookCallback callback = new FacebookCallback() {
@Override
public void onSuccess(LoginResult loginResult)
{

        GraphRequest.newMeRequest(
                loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {

                    public void onCompleted(JSONObject me, GraphResponse response) {
                        if (response.getError() != null) {
                            textView.setText("Error");
                        } else {
                            String email = me.optString("email").toString();
                            textView1.setText(email);

                        }
                    }
                }).executeAsync();


    }


Source: facebook

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.