简体   繁体   English

如何使用SDK 3.0在Android中存储Facebook的登录状态

[英]How to store login state of Facebook in Android with SDK 3.0

I have not push "Log out" ,how to keep "Log in" state ? 我还没有按下“注销”,如何保持“登录”状态?

anyway,I restart program etc. (I use Facebook sdk 3.0) 无论如何,我会重新启动程序等。(我使用Facebook sdk 3.0)

Try this, 尝试这个,

  1. You can get the accesstoken from the first valid session. 您可以从第一个有效会话中获取访问令牌。

     String token = session.getAccessToken() 

    Then save this in sharepreferences. 然后将其保存在sharepreferences中。

  2. Then before you procceed with other functions, read the stored session is check weather the session is not null and is open. 然后,在继续使用其他功能之前,请先读取存储的会话,以检查该会话不为空且已打开。

     if(session.isOpened()) { //proceed } 

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

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