saveInBackground抛出异常"未保存的ParseObject"

时间:2014-12-03 21:54:28

标签: android parsing

我试图保存与我的图像类有关系的项目。我可以保存该项目,我可以单独保存图像,但是当我使用关系保存它们时如果抛出此错误:

unable to encode an association with an unsaved ParseObject

这是我的代码:

myAdvert = new ParseObject("Items");
myAdvert.put("title", "some title");
if (pic1Set) {
    Bitmap bitmap = ((BitmapDrawable) pic1.getDrawable())
                    .getBitmap();
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
    byte[] byteArray = stream.toByteArray();
    myPhoto1 = new ParseObject("Images");

    filePhoto = new ParseFile("image.png", byteArray);
    filePhoto.saveInBackground(new SaveCallback() {

        @Override
        public void done(ParseException e) {
            if (e == null) {
                myPhoto1.put("image", filePhoto);
                ParseRelation relation = myAdvert.getRelation("pictures");
                relation.add(myPhoto1);
                myAdvert.saveInBackground(new SaveCallback() {

                    @Override
                    public void done(ParseException e) {
                        // TODO Auto-generated method stub
                        if (e != null) {
-->                         // THIS IS WHERE THE ERROR IS THROWN!!!!
                            Log.d("error", e.toString());
                        } else {

                            }
                        }
                    });
                } else {
                    Log.d("wow, error", e.toString());
                    Toast.makeText(getApplicationContext(),
                        "Error saving: " + e.getMessage(),
                        Toast.LENGTH_SHORT).show();
                }
            }

        });

1 个答案:

答案 0 :(得分:1)

让我们考虑一下这个评论和一些额外的信息,而不是一个答案 -

我在尝试登录时遇到同样的异常但是只有在本地数据存储工作完成后才能完成离线操作后才会发生这种异常 我也有ACL。 我猜它与尝试以错误的顺序或其他东西保存离线工作中的东西有关。

我正在调试我的 - 祝我们所有人好运 - 如果你找到了什么,请告诉我。

相关问题