Parse.com为对象返回null

时间:2015-06-12 11:10:26

标签: java android parse-platform

我正在尝试从parse.com获取对象。但我得到一个空的物体。这就是上课。

Screenshot

这是我的代码。

ParseQuery<ParseObject> query = ParseQuery.getQuery("AppDate");
    query.getInBackground("lOtmkstVaR", new GetCallback<ParseObject>() {
        public void done(ParseObject object, ParseException e) {
            if (e == null) {
                Log.d("DATA", object.getObjectId());
            } else {
                // something went wrong
                e.printStackTrace();
            }
        }
    });

这是我的logcat。

06-12 10:57:20.203    7512-7512/com.andromedatech.onlineradio W/System.err﹕ com.parse.ParseException: no results found for query
06-12 10:57:20.273    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at com.parse.AbstractParseQueryController$1.then(AbstractParseQueryController.java:26)
06-12 10:57:20.273    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at com.parse.AbstractParseQueryController$1.then(AbstractParseQueryController.java:17)
06-12 10:57:20.273    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task$13.run(Task.java:755)
06-12 10:57:20.273    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
06-12 10:57:20.273    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task.completeImmediately(Task.java:746)
06-12 10:57:20.274    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task.access$100(Task.java:31)
06-12 10:57:20.274    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task$9.then(Task.java:538)
06-12 10:57:20.274    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task$9.then(Task.java:535)
06-12 10:57:20.274    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task.runContinuations(Task.java:832)
06-12 10:57:20.274    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task.access$600(Task.java:31)
06-12 10:57:20.274    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task$TaskCompletionSource.trySetResult(Task.java:887)
06-12 10:57:20.274    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task$TaskCompletionSource.setResult(Task.java:921)
06-12 10:57:20.274    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task$14$1.then(Task.java:813)
06-12 10:57:20.274    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task$14$1.then(Task.java:800)
06-12 10:57:20.274    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task$13.run(Task.java:755)
06-12 10:57:20.275    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
06-12 10:57:20.275    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task.completeImmediately(Task.java:746)
06-12 10:57:20.275    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task.continueWith(Task.java:545)
06-12 10:57:20.275    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task.continueWith(Task.java:556)
06-12 10:57:20.275    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at bolts.Task$14.run(Task.java:800)
06-12 10:57:20.275    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-12 10:57:20.275    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-12 10:57:20.275    7512-7512/com.andromedatech.onlineradio W/System.err﹕ at java.lang.Thread.run(Thread.java:818)

我刚开始使用parse.com后端服务。我正在使用parse.com指南。

2 个答案:

答案 0 :(得分:1)

您在查询中输入了一个简单的拼写错误。您的班级名称为AppData,但您已使用AppDate。它应该是

ParseQuery<ParseObject> query = ParseQuery.getQuery("AppData");

答案 1 :(得分:0)

我也有这个错误。是由解析引起的,不返回“ParseObject”,只是和对象,这里我的代码对我来说很好用:

ParseQuery query = new ParseQuery("Your_class_name");
query.getInBackground(imagenID, new GetCallback() {

@Override
                            public void done(Object o, Throwable throwable) {
                            ParseObject object = (ParseObject) o;
                            ParseFile foto = (ParseFile) object.get("Your_column_name");
                            foto.getDataInBackground(new GetDataCallback() {
                                @Override
                                public void done(byte[] bytes, ParseException e) {
                                    if (e == null) {
                                        //do your things like decoding to a Bitmap
                                    } else {
                                        Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
                                        e.printStacktrace();

                                    }
                                }
                            });

                        }
                   }

只需将“完成”替换为“完成”。它对我来说很完美