简体   繁体   中英

Facebook Android SDK logging in automatically

I have just started using Facebook's Official Android SDK and wrote their sample login app ( http://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/ 6th Step). It's working fine, I mean not force closing or giving any error, except what I notice is it never asks me for any login information.

Whenever I start the app, it automatically logs me in somehow. I logged out from Facebook app installed, logged out of Facebook from my browser, still it never asks for my E-mail and password. However, when I exported it as an .apk and gave it to friend, there it asked for his email and password.

How should I get the login screen in my app on my cell then? Thanks :)

If the Facebook SDK finds a valid authentication token it will automatically log you in. This can occur if you have the official Facebook app installed on your device and I don't think that logging out delete this token at all. So your friends simple don't have the app, or a valid token.

With this code you can clear the session and also the token

Session session = Session.getActiveSession();
if (session != null){
     session.closeAndClearTokenInformation();
     session = null;
     Log.i(TAG, "cleared session");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM