解析回调完成(Object,Throwable)而不是done(ParseObject,ParseException)

时间:2015-11-16 07:03:13

标签: android parse-platform callback

我现在正尝试将Parse用于Android应用,并且在完成保存到服务器之后我想要使用ParseObject做一些事情。回调应该是调用done(ParseObject, ParseException),但由于某种原因,它会进入done(Object, Throwable)方法。有什么线索的原因?

ParseObject event = new ParseObject("Event");
event.saveInBackground(new SaveCallback() {
    @Override
    public void done(ParseObject parseObject, ParseException e) {
        if (e == null) {
            // code in here should be executing
        }
    }

    @Override
    public void done(Object o, Throwable throwable) {
        // but instead, code in here is actually executing
    }
}

2 个答案:

答案 0 :(得分:0)

SaveCallback不会返回ParseObject。只有在Exception

保存对象时才会显示parse.com
ParseObject event = new ParseObject("Event");
    event.saveInBackground(new SaveCallback() {

        @Override
        public void done(ParseException arg0) {
            // TODO Auto-generated method stub

        }
    });

答案 1 :(得分:0)

尝试这种方式。

        ParseObject event = new ParseObject("Event");
    event.put("hear Class Field name", "hear new value from user input");
    // before u want to save in background set user psermission for read &
    // write like this way
    ParseACL postACL = new ParseACL(ParseUser.getCurrentUser());
    postACL.setPublicReadAccess(true);
    postACL.setPublicWriteAccess(true);
    event.setACL(postACL);

    event.saveInBackground(new SaveCallback() {

        @Override
        public void done(ParseException e) {
            // TODO Auto-generated method stub
            if (e == null) {
                // hear u will get success message
            } else {
                // and hear u will get fail message
                // also get which error throw like
                Log.e("testing ", "get error code " + e.getCode()
                        + " get Error Message " + e.getMessage());
            }
        }
    });