saveInBackground 回调不起作用 [英] saveInBackground callback doesn't work

查看:37
本文介绍了saveInBackground 回调不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多次调用下面的代码(5-10 次)后,SaveCallback 的 done() 方法没有触发,整个应用程序似乎卡住了.似乎这个请求破坏了请求队列,所有进一步的查询也不会触发它们的回调.回调和日志中没有错误."BEFORE SAVING" - 显示在日志中,而"SAVED" - 没有.

After calling code below for several times(5-10 times), done() method for SaveCallback doesn't fire and whole application seems to stuck. It seems that this request ruins request queue and all further queries doesn't fire their callbacks either. No errors in callbacks and in logs. " BEFORE SAVING" - displayed in logs, while " SAVED" - didn't.

我是否需要更改解析定价合同,或者以某种方式更改我的代码?

Do I need to change parse pricing contract, or to change my code somehow?

    Log.d("MESSAGE OBJECT", " BEFORE SAVING");
    messageParseObject.saveInBackground(new SaveCallback() {
        @Override
        public void done(final ParseException e) {
            Log.d("MESSAGE OBJECT", " SAVED");
            if (e != null){
                completitionCallback.error(e);
                return;
            }

            chatObject.put(ModelConstants.LAST_MESSAGE_KEY, messageParseObject);
            chatObject.getRelation(ModelConstants.MESSAGES_KEY).add(messageParseObject);                
            chatObject.saveInBackground(new SaveCallback() {
                @Override
                public void done(ParseException e) {
                    Log.d("CHAT OBJECT", " SAVED");
                    if (e == null)
                        completitionCallback.success();
                    else
                        completitionCallback.error(e);
                }
            });
        }
    });

推荐答案

面对这个真的让我发疯.这是我发现的.如果在 Parse.com 中已经创建了 Class,即使有一个小的差异,saveInBackground 和 saveEventually 也会失败,没有任何错误.

Faced this and really drove me crazy. This is what I found. If the Class is already created in Parse.com, even if there is a small discrepancy saveInBackground and saveEventually fails without any error.

如果发生这种情况,最好的方法是删除 Parse.com 中创建的类,并让 android SDK 在第一次调用时自动调用它.

Best way, if this happens is to delete the created class in Parse.com and let the android SDK call it it automatically in the first invocation.

至少这对我有用.

这篇关于saveInBackground 回调不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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