I need to log in to Facebook and get same fields like email, etc. I use the Facebook SDK, and I set my Android key Hash in developers.facebook and set \"Configured for Andro
I had the same problem like you. Finally, I solved using this:
Open Facebook.java provided by the Facebook SDK and then change it like this:
public void authorize(Activity activity, String[] permissions,
int activityCode, final DialogListener listener) {
boolean singleSignOnStarted = false;
mAuthDialogListener = listener;
/*
// Prefer single sign-on, where available.
if (activityCode >= 0) {
singleSignOnStarted = startSingleSignOn(activity, mAppId,
permissions, activityCode);
}
// Otherwise fall back to the traditional dialog.
if (!singleSignOnStarted) {
*/
startDialogAuth(activity, permissions);
// }
}
Please update the below code of your application. It will solve your problem.
public void loginAndPostToWall() {
facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH,
new LoginDialogListener());
}
This is just a wild guess, but instead of this:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
this.facebookConnector.getFacebook().authorizeCallback(requestCode, resultCode, data);
}
Try:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
this.facebookConnector.getFacebook().authorizeCallback(requestCode, resultCode, data);
}
Since you're not calling the parent method some things might not work as expected...
private static Session openActiveSession(Activity activity, boolean allowLoginUI, StatusCallback callback, List<String> permissions) {
OpenRequest openRequest = new OpenRequest(activity).setPermissions(permissions).setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO).setCallback(callback);
Session session = new Session.Builder(activity).build();
if (SessionState.CREATED_TOKEN_LOADED.equals(session.getState()) || allowLoginUI) {
Session.setActiveSession(session);
session.openForRead(openRequest);
return session;
}
return null;
}
Edit your openactivesession function like this