Android : android-fb-sdk email is always null

on Tuesday, October 28, 2014


I have a big problem with android-facebook-sdk 3.19.1. No problem to retrieve public information about user but it is not possible getting email address.


I know my post is very near to the following thread ==> facebook android sdk -user email returns null but I have no solution for now.


So here is my code


In my ConnectionActivity.java I have a button R.id.fb_connect



private List<String> permissions = Arrays.asList("email");

@Click(R.id.fb_connect)
protected void fbConnect() {
ensureOpenSession();
}

private boolean ensureOpenSession() {
Session session = Session.getActiveSession();
if (session == null || !session.isOpened()) {
LOGD(TAG, "Call Session.openActiveSession");
Session.openActiveSession(this, true, permissions, new FbCallback());
return false;
}
return true;
}

public class FbCallback implements Session.StatusCallback {

@Override
public void call(Session session, SessionState sessionState, Exception e) {
// make request to the /me API
Request.newMeRequest(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
// user.asMap().get("email");
Toast.makeText(ConnectionActivity.this, "email : " + user.getProperty("email"), Toast.LENGTH_LONG).show();
}
}
}).executeAsync();
}
}


I've also tried the code in the link above but it doesn't work.


Thx


0 comments:

Post a Comment