I have set up simple facebook login. For Android 2.3.6 everything works as should, user gets prompt login dialog, enters data and app goes on. I thought that it was android versions fault but it turs out that the login isn't working when there is facebook application installed on the phone!
Tested this on: Galaxy Ace 2.3.6 HTC Desire 4.1.2 Galaxy Note 4.1.2 Android emulator 4.1.2
Even the facebook samples are not working!
Every time the app is executing - else {
Log.d("SESSION NOT OPENED", "SESSION NOT OPENED");
}
It seems like session isn't opened but why is that? Followed this guide - https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/
Code:
Session.openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(final Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
Log.d("Access_token", session.getAccessToken());
}
}
});
} else {
Log.d("SESSION NOT OPENED", "SESSION NOT OPENED");
}
}
});
Check For Updates (Android and iOS). If you cannot access your account on the app but can log in on Facebook's website, then try to update your Facebook app. Possibly, the version of Facebook installed on your device is no longer supported, or it contains a bug or glitch related to logging in.
Try refreshing your browser or reopening the site; on a mobile app, close and reopen the app. You can also check to see if Facebook is offline and then restart your device, update apps, and clear your cache.
i am writting this answer for those who are using Facebook SDK 4.X
you can open login portal of facebook in either of the two ways :
if you have an android device with Android 1.9.X
and Facebook App
is Installed in device called Native Login
Method here, you don't need to use facebook WebView
if you have not installed Facebook App
in your Android device then it's good to use WebView
so for this Facebook provide 3 Constants
NATIVE_ONLY
(used when you want to open in Facebook App only)WEB_ONLY
(used when you want to open in WebView
only)NATIVE_WITH_FALLBACK
(Recommended Facebook detect and opne webView
if app is not installed)Check below link for detail https://developers.facebook.com/docs/reference/android/current/class/LoginButton/ https://developers.facebook.com/docs/facebook-login/android/v2.2#troubleshooting
LoginButton.setLoginBehavior(LoginBehavior.NATIVE_WITH_FALLBACK);
LoginButton.setLoginBehavior(LoginBehavior.NATIVE_ONLY);
LoginButton.setLoginBehavior(LoginBehavior.WEB_ONLY);
Check out the bottom of step 4: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/
If you have not entered your app key hash properly, Facebook login via the WebView popup (if the app is not installed) will still work, but login via the native Facebook app won't.
You should see this exception in LogCat:
com.facebook.http.protocol.ApiException: remote_app_id does not match stored id
The Facebook SDK prints its exceptions so check there anyway if there are other problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With