0

I am using a TextView to show Name and Email of logged in facebook user, but i really don't know How do I fetch Name and Email ?

private void onSessionStateChange(Session session, SessionState state,
                                  Exception exception) {
    if (session != currentSession) {
        return;
    }

    if (state.isOpened()) {
        // Log in just happened.
        Toast.makeText(getApplicationContext(), "session opened",
                Toast.LENGTH_SHORT).show();
    } else if (state.isClosed()) {
        // Log out just happened. Update the UI.
        Toast.makeText(getApplicationContext(), "session closed",
                Toast.LENGTH_SHORT).show();
    }
}
Oreo
  • 2,586
  • 8
  • 38
  • 63

1 Answers1

1

You can get the name and email as below:

// use their Facebook info
    JSONObject json = Util.parseJson(facebook.request("me"));
    String facebookID = json.getString("id");
    String firstName = json.getString("first_name");
    String lastName = json.getString("last_name");
    Toast.makeText(uiActivity,"Thank you for Logging In, " 
                 + firstName + " " 
                 + lastName + "!"
                 , Toast.LENGTH_SHORT).show();
Dyrandz Famador
  • 4,499
  • 5
  • 25
  • 40
jyomin
  • 1,957
  • 2
  • 11
  • 27