问题描述
我在 Android 上玩 Parse 已经有几天了,我在使用 ParseUser.logOut() => 时遇到了问题,它实际上并没有将当前用户注销.
I've been playing around with Parse on Android for a few days, I have a problem with ParseUser.logOut() => it actually doesn't log the current user out.
这就是我所做的:
private void onClickOnDisconnect() {
ParseUser.logOut();
currentUser = ParseUser.getCurrentUser(); // should be null but isn't...
invalidateOptionsMenu();
Toast.makeText(getApplicationContext(), "Disconnected...", Toast.LENGTH_LONG).show();
}
在调用 ParseUser.logOut()
之后,ParseUser.getCurrentUser()
应该返回 null(文档说).它仍然返回以前登录的用户.即使我重新启动应用程序,用户仍被视为已连接.
After the call to ParseUser.logOut()
, ParseUser.getCurrentUser()
should return null (says the documentation). Still it returns the previously logged in user.Even though I restart the app the user is still considered as connected.
我使用解析框架 v1.3.8(3 天前下载).我不使用 Facebook SDK,因为我看到了一些针对该特定案例的问题.
I use parse framework v1.3.8 (downloaded a 3 days ago). I don't use Facebook SDK, as I've seen a few questions for that specific case.
提前致谢
推荐答案
我在将注销功能与 facebook 登录合并时遇到了同样的问题.结果证明这个错误非常简单,而且是我的一个基本错误.我在我的应用程序类中编写了以下代码
I had the same issue while incorporating logout functionality with facebook login. The error turned out to quite simple and a basic mistake on my part. I had written the following piece of code in my Application class
ParseUser.enableAutomaticUser();
ParseUser.enableAutomaticUser();
这会在您每次运行应用程序时创建用户,即使您上次退出也是如此.删除它解决了我的问题.
This creates the user every time you run your application even if you have logged out the last time around. Removing this solved my problem.
这篇关于Parse for Android:ParseUser.logOut() 不会注销用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!