Skip to content

Instantly share code, notes, and snippets.

@ppapageorgiou
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppapageorgiou/38b5b4ea4c38b8d6994a to your computer and use it in GitHub Desktop.
Save ppapageorgiou/38b5b4ea4c38b8d6994a to your computer and use it in GitHub Desktop.
Open Facebook Session
private void openFacebookSession() {
// Open a Facebook session to get the user's name
Session.openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
Request.newMeRequest(session, new Request.GraphUserCallback() {
// Response Callback
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
TextView welcome = (TextView) findViewById(R.id.welcomeText);
welcome.setText("Welcome " + user.getFirstName() + "!");
}
}
}).executeAsync();
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment