解析本地数据存储:从网络的力量在关闭应用程序后,我无法访问ACL的安全对象? (安卓) [英] Parse Local Datastore: I can't access ACL secured objects from the network after force closing the app? (Android)

查看:195
本文介绍了解析本地数据存储:从网络的力量在关闭应用程序后,我无法访问ACL的安全对象? (安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在成功登录我打电话:

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

现在,如果我切换到经由home键或者多任务处理另一个应用程序,并返回到我的应用程序中的currentUser通过身份认证。

但是,如果我强行关闭应用程序,然后重新打开它的currentUser未通过身份验证。因此,看来我不能访问从网络上具有访问控制列表(ACL),通过添加到它们的默认任何对象:

  Parse.enableLocalDatastore(本);
ParseACL.setDefaultACL(新ParseACL(),TRUE);
 

更新与样​​品code:

  //钢钉
    的parseObject gameScore =新的parseObject(GameScore);
    gameScore.put(分数,1337);
    gameScore.put(playerName,肖恩普洛特);
    gameScore.put(cheatMode,假);
    gameScore.pinInBackground(NEW_GAMESCORES,NULL);

    //正在同步本地更改
    ParseQuery<的parseObject> localQueryNewScores = ParseQuery
            .getQuery(GameScore);
    localQueryNewScores.fromPin(NEW_GAMESCORES);

    localQueryNewScores.findInBackground(新FindCallback<的parseObject>(){
        公共无效完成(名单<的parseObject>的分数,ParseException的E){

            Log.d(得分,新得分=+ scores.size());

            对于(的parseObject评分:分数){
                score.saveInBackground();
                score.unpinInBackground(NEW_GAMESCORES,NULL);

                score.pinInBackground(GAMESCORES,NULL);
            }
        }
    });

    //正在同步网络改变
    ParseQuery<的parseObject> networkQueryScores = ParseQuery
            .getQuery(GameScore);

    //查询从网络新的结果。
    networkQueryScores.findInBackground(新FindCallback<的parseObject>(){
        公共无效完成(最终名单,其中,的parseObject>的分数,ParseException的E){

            Log.d(得分,网络分数=+ scores.size());

            //删除previously缓存的结果。
            ParseObject.unpinAllInBackground(GAMESCORES
                    新DeleteCallback(){
                        公共无效完成(ParseException的E){
                            //缓存中的新成果。
                            ParseObject.pinAllInBackground(GAMESCORES
                                    分数);
                        }
                    });
        }
    });

    //查询本地数据存储
    ParseQuery<的parseObject> localQueryScores = ParseQuery
            .getQuery(GameScore);
    localQueryScores.fromPin(GAMESCORES);

    localQueryScores.findInBackground(新FindCallback<的parseObject>(){
        公共无效完成(名单<的parseObject>的分数,ParseException的E){
            Log.d(得分,本地分数=+ scores.size());
        }
    });
 

日志输出就在我已经跑了code几次:

 新成绩= 2
本地分数= 0
网络分数= 0

新分数= 0
本地分数= 0
网络分数= 2

新分数= 2
本地分数= 2
网络分数= 2

新的得分= 1
本地分数= 2
网络分数= 4
 

日志输出就在我已经强制关闭应用程序:

 新成绩= 0
本地分数= 4
网络分数= 0

新分数= 2
本地分数= 0
网络分数= 0
 

正如你可以在看网络分数= 0 力收盘后我无法查询到我的 //查询网络上的任何结果从网络上的新成果更新的本地数据存储在固定的对象从网络新成果。发生这种情况,即使我不断地连接到互联网,在首次登录后。

不过,因为我需要同步回从网络上的本地数据存储,我根据这个查询的变化。

那么,如何我还可以查询网络存储与ACL添加中的currentUser后,我强制关闭应用程序对象?

更新2

我发现别人与已经在这里报告了同样的问题: developers.facebook.com/bugs/702967266408226

这似乎是在新的解析Android SDK中1.5的错误。因为很明显,我的问题是有关该报告的bug,我会尽快更新这个帖子。

解决方案
  

解析Android的更新日志

     

V1.5.1 - 二零一四年五月三十〇日

     

修正各种错误与本地数据存储。

这个问题确实是已经固定的今天与新解析的Andr​​oid SDK版本的发布1.5.1。

本地数据存储错误

After a successful login I'm calling:

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

Now if I switch to another app via the home button or multitasking and return to my app the currentUser is still authenticated.

But if I force close the app and then reopen it the currentUser is not authenticated. Therefore it seems that I can't access any objects from the network which have the default Access Control List (ACL) added to them via:

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

Update with sample code:

    // 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());
        }
    });

Log output just after I've ran the code several times:

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

Log output just after I've force closed the app:

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

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

As you can see at Network scores = 0 after the force close I am unable to query any results from the network where I // Query for new results from the network to update the pinned objects in the Local Datastore with new results from the network. This happens even though I am constantly connected to the internet after the first login.

But as I need to sync back changes from the network to the Local Datastore I'm depending on this query.

So how can I still query the network for objects that are stored with ACL added to the currentUser, after I force close the app?

Update 2

I found others with the same problem which has been reported here: developers.facebook.com/bugs/702967266408226

It seems to be a bug in the new Parse Android SDK 1.5. I will update this post as soon as it's clear that my problem was related to the reported bug.

解决方案

Parse Android Changelog

v1.5.1 — May 30, 2014

Fixed various bugs with Local Datastore.

The problem was indeed a Local Datastore bug which has been fixed today with the release of the new Parse Android SDK version 1.5.1.

这篇关于解析本地数据存储:从网络的力量在关闭应用程序后,我无法访问ACL的安全对象? (安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆