简体   繁体   中英

Parse.com Returns null for object

I am trying to fetch object from parse.com. But I get an empty object.Here is the class.

截屏

And here is my code.

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();
            }
        }
    });

And here is my 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)

I just started using parse.com back-end service. I am using parse.com guide.

You have made a simple typo in your query. Your class name is AppData but you have used AppDate . It should be

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

I had this error too. Is caused by parse don't return a "ParseObject", just and object, here my code which works fine for me:

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();

                                    }
                                }
                            });

                        }
                   }

just replace your "done" for my "done". It works perfectly for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM