In a project I'm doing, I have to log in through Facebook.
I'm already getting that, however, I only get this for LoginButton
of the Facebook SDK itself using these methods:
private static final List<String> PERMISSIONS = Arrays.asList("email", "public_profile", "user_friends");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_login);
btnFacebook();
LoginButton fbLogin = (LoginButton) findViewById(R.id.fbLogin);
fbLogin.setPublishPermissions(Arrays.asList("email", "public_profile", "user_friends"));
Session.openActiveSession(LoginActivity.this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(Session session, SessionState state,
Exception exception) {
if (session.isOpened()) {
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(
LoginActivity.this, PERMISSIONS);
session.requestNewReadPermissions(newPermissionsRequest);
return;
}
// make request to the /me API
Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
//TODO Auto-generated method stub
try {
Log.i("Name", "" + user.getFirstName() + " " + user.getLastName());
Log.i("Email", "" + user.getProperty("email").toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).executeAsync();
}
}
});
}
private boolean isSubsetOf(Collection<String> subset,
Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}
How do I use a button, what do I do?