gpt4 book ai didi

java - 解析本地数据存储 : I can't access ACL secured objects from the network after force closing the app? (Android)

转载 作者:行者123 更新时间:2023-11-29 08:49:07 25 4
gpt4 key购买 nike

成功登录后我打电话:

ParseUser currentUser = ParseUser.getCurrentUser();
currentUser.isAuthenticated()

现在,如果我通过主页按钮或多任务切换到另一个应用程序并返回到我的应用程序,则 currentUser 仍然经过身份验证。

但如果我强行关闭应用程序然后重新打开它,则当前用户未通过身份验证。因此,我似乎无法通过以下方式访问网络中添加了默认访问控制列表 (ACL) 的任何对象:

Parse.enableLocalDatastore(this);
ParseACL.setDefaultACL(new ParseACL(), true);

更新示例代码:

    // Pinning
ParseObject gameScore = new ParseObject("GameScore");
gameScore.put("score", 1337);
gameScore.put("playerName", "Sean Plott");
gameScore.put("cheatMode", false);
gameScore.pinInBackground("NEW_GAMESCORES", null);

// Syncing Local Changes
ParseQuery<ParseObject> localQueryNewScores = ParseQuery
.getQuery("GameScore");
localQueryNewScores.fromPin("NEW_GAMESCORES");

localQueryNewScores.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> scores, ParseException e) {

Log.d("score", "New scores = " + scores.size());

for (ParseObject score : scores) {
score.saveInBackground();
score.unpinInBackground("NEW_GAMESCORES", null);

score.pinInBackground("GAMESCORES", null);
}
}
});

// Syncing Network Changes
ParseQuery<ParseObject> networkQueryScores = ParseQuery
.getQuery("GameScore");

// Query for new results from the network.
networkQueryScores.findInBackground(new FindCallback<ParseObject>() {
public void done(final List<ParseObject> scores, ParseException e) {

Log.d("score", "Network scores = " + scores.size());

// Remove the previously cached results.
ParseObject.unpinAllInBackground("GAMESCORES",
new DeleteCallback() {
public void done(ParseException e) {
// Cache the new results.
ParseObject.pinAllInBackground("GAMESCORES",
scores);
}
});
}
});

// Querying the Local Datastore
ParseQuery<ParseObject> localQueryScores = ParseQuery
.getQuery("GameScore");
localQueryScores.fromPin("GAMESCORES");

localQueryScores.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> scores, ParseException e) {
Log.d("score", "Local scores = " + scores.size());
}
});

在我多次运行代码后记录输出:

New scores = 2
Local scores = 0
Network scores = 0

New scores = 0
Local scores = 0
Network scores = 2

New scores = 2
Local scores = 2
Network scores = 2

New scores = 1
Local scores = 2
Network scores = 4

在我强行关闭应用程序后立即记录输出:

New scores = 0
Local scores = 4
Network scores = 0

New scores = 2
Local scores = 0
Network scores = 0

正如您在强制关闭后在 Network scores = 0 看到的那样,我无法从网络中查询任何结果,我在其中 //Query for new results from the network 使用来自网络的新结果更新本地数据存储中的固定对象。即使我在第一次登录后一直连接到互联网,也会发生这种情况。

但由于我需要将更改从网络同步回本地数据存储,因此我依赖于此查询。

那么在我强行关闭应用程序后,我如何仍然可以查询网络以查找存储在 ACL 中并添加到 currentUser 的对象?

更新2

我发现其他人也有同样的问题,已在此处报告: developers.facebook.com/bugs/702967266408226

这似乎是新的 Parse Android SDK 1.5 中的错误。一旦确定我的问题与报告的错误有关,我会尽快更新这篇文章。

最佳答案

也许将密码保存到文件中,如果您在强制关闭后重新打开应用程序,请使用保存的密码登录?

关于java - 解析本地数据存储 : I can't access ACL secured objects from the network after force closing the app? (Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23586362/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com