Facebook Oncompleted Email Java.lang.nullpointerexception
I'm able to get all those things as shown in my code below, but unable to retrieve email from the user profile. What can I do for this? Any kind of help will be appreciated. Earlie
Solution 1:
Sometime it might be happen that User not set their Email Id in their Profile which are you getting in Your Facebook Login Via Android so that throws Error like Null Pointer Exception.
So You should have to check before using the Email Variable after fetching from Login that it is null or not Such as :
String email ="";
if(user.asMap().get("email") != null){
email = user.asMap().get("email").toString();
}
Solution 2:
You need to add "email" to the list of permissions you're requiring, otherwise the email will always be null. I don't know what version of the sdk you're using. With the last one you can write:
Collection<String> mPermissions = newArrayList<>();
mPermissions.add("email");
LoginManagermLoginManager= LoginManager.getInstance();
CallbackManagermCallbackManager= CallbackManager.Factory.create();
FbCallbackfbCallback=newFbCallback(this);
mLoginManager.registerCallback(mCallbackManager, fbCallback);
[...]
mLoginManager.logInWithReadPermissions(this, mPermissions);
By the way...remember that the user can revoke the permission or cannot grant it during the login.
Post a Comment for "Facebook Oncompleted Email Java.lang.nullpointerexception"