This is my code for logging in to facebook.
mLoginButton = (LoginButton) findViewById(R.id.login);
// restore session if one exists
SessionStore.restore(Utility.mFacebook, this);
SessionEvents.addAuthListener(new FbAPIsAuthListener());
SessionEvents.addLogoutListener(new FbAPIsLogoutListener());
/*
* Source Tag: login_tag
*/
mLoginButton.init(this, AUTHORIZE_ACTIVITY_RESULT_CODE, Utility.mFacebook, permissions);
if (Utility.mFacebook.isSessionValid()) {
requestUserData();
}
public class FbAPIsAuthListener implements AuthListener {
//@Override
public void onAuthSucceed() {
requestUserData();
}
//@Override
public void onAuthFail(String error) {
mText.setText("Login Failed: " + error);
}
}
/*
* The Callback for notifying the application when log out starts and
* finishes.
*/
public class FbAPIsLogoutListener implements LogoutListener {
//@Override
public void onLogoutBegin() {
mText.setText("Logging out...");
}
///@Override
public void onLogoutFinish() {
mText.setText("You have logged out! ");
mUserPic.setImageBitmap(null);
}
}
On emulator it works perfect. I have tried in ton 3 devices, that have already facebook installed and here is the problem.
it just spinning aroun on loading and it does nothing. I see the login button again. Then i tried to logout from the original facebook application, and when pressing the login button on my app, i see the login window but now that I used to see when logging in the emulator but the login window of the original facebook application. Like is has started this one.
the code I am using is taken from the hackbook.java
Open Facebook Settings (using the mobile app or website version). Make sure you have allowed the use of Facebook to sign in to third-party sites and applications (Settings-> Apps and Websites-> tap on the Edit button in the Apps, Websites and Games section-> check if the setting is turned on).
The Platform Status says that there's a problem with the SSO.
The SSO only works if you have the facebook application installed on the android device, and what you describe fits right into all of this. On the emulator you don't have the facebook application, and so when your application tries to log the user in it uses the dialog it has in the sdk instead of using the SSO process that ships with the fb application.
On the device how ever you said that you do have the fb app, and so the SSO kicks in and, at least currently, there's a problem with it. Try to uninstall the facebook application on the device or maybe just cancel the SSO, i.e.: How to disable Facebook single sign on for android - Facebook-android-sdk
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