Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

android - saveInBackground callback doesn't work

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);
                }
            });
        }
    });
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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.

At least that did the trick for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...