Get facebook email after login in Android
You need the email
permission to read the users email adress.That will add a email tag in your json-response from [uid]
or me
requests.
Provides access to the user's primary email address in the email property. Do not spam users. Your use of email must comply both with Facebook policies and with the CAN-SPAM Act.
Source: Permissions
Do it when you are clicking Login button:
OpenRequest openRequest = new OpenRequest(this); List<String> readPermissions = new ArrayList<String>(); readPermissions.add("email"); openRequest.setPermissions(readPermissions); openRequest.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK); openRequest.setCallback(statusCallback); session.openForRead(openRequest);
Another option to retrieve email in Facebook SDK 3.0.x is by using this open source library:
android-simple-facebook
https://github.com/sromku/android-simple-facebook
First, use this permission
Permissions.EMAIL
Then, login
mSimpleFacebook.login(MainActivity.this);
And then, get the profile
mSimpleFacebook.getProfile(new OnProfileRequestAdapter(){ @Override public void onComplete(Profile profile) { String id = profile.getId(); String firstName = profile.getFirstName(); String birthday = profile.getBirthday(); String email = profile.getEmail(); String bio = profile.getBio(); // ... and many more properties of profile ... }});
Full examples are explained here including permissions stuff and other simplified methods (like: publish feeds, get friends and more...)