toggle menu

Email from Facebook in android

Vibhu Vikram Singh |02 Apr at 01:04

How to get an email from Facebook on android?

  • 1 like
  • 1 comment

Govind Ramchander02 Apr at 01:04

You Can get an email like this.....

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

callbackManager = CallbackManager.Factory.create();

// Callback registration
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
Log.v("LoginActivity", response.toString());

// Application code
String email = object.getString("email");
String birthday = object.getString("birthday"); // 01/31/1980 format
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender,birthday");
request.setParameters(parameters);
request.executeAsync();


}

@Override
public void onCancel() {
// App code
Log.v("LoginActivity", "cancel");
}

@Override
public void onError(FacebookException exception) {
// App code
Log.v("LoginActivity", exception.getCause().toString());
}
});
}

Posted:

02 Apr at 01:04

Viewed:

533 times

Active:

06 Apr at 10:04