Java 登出 Facebook Android SDK
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24149438/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Logout Facebook Android SDK
提问by MikkoP
I use the LoginButton
from the Facebook Android SDK to login to my application. How do I programmatically log out the user from any Activity?
我使用LoginButton
来自 Facebook Android SDK 的 登录到我的应用程序。如何以编程方式从任何活动中注销用户?
采纳答案by Roemer
Can you use closeAndClearTokenInformation()
as described here: https://developers.facebook.com/docs/reference/android/current/class/Session/?
你能closeAndClearTokenInformation()
像这里描述的那样使用:https: //developers.facebook.com/docs/reference/android/current/class/Session/?
See also How to programmatically log out from Facebook SDK 3.0 without using Facebook login/logout button?
回答by Tarun
Starting Facebook SDK 4.0 you need to call
启动 Facebook SDK 4.0 你需要调用
LoginManager.getInstance().logOut();
回答by Rob
回答by Nimit Patel
If you are using facebook SDK 4, you first need to initialize sdk:
如果您使用的是 facebook SDK 4,您首先需要初始化 sdk:
FacebookSdk.sdkInitialize(getApplicationContext());
And then :
进而 :
LoginManager.getInstance().logOut();
AccessToken.setCurrentAccessToken(null);