简体   繁体   English

Facebook Android SDK自动登录

[英]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). 我刚刚开始使用Facebook的官方Android SDK并编写了他们的示例登录应用程序( http://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/第六步)。 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. 我从已安装的Facebook应用程序注销,从我的浏览器注销了Facebook,但仍然从不要求输入我的电子邮件和密码。 However, when I exported it as an .apk and gave it to friend, there it asked for his email and password. 但是,当我将其导出为.apk并将其提供给朋友时,在那里询问他的电子邮件和密码。

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. 如果Facebook SDK找到有效的身份验证令牌,它将自动登录。如果您在设备上安装了官方的Facebook应用程序,并且我认为注销根本不会删除此令牌,则可能会发生这种情况。 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");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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