5
votes

I am trying to use Parse to program an Android app. I am following the tutorial on this link: https://www.parse.com/docs/android_guide

While the tutorial/guide is fairly straight forward, I am having problem with a query to the Parse database. The specific part of the guide is: https://www.parse.com/docs/android_guide#objects-retrieving

Code from relevant section:

ParseQuery<ParseObject> query = ParseQuery.getQuery("GameScore");
query.getInBackground("xWMyZ4YEGZ", new GetCallback<ParseObject>(){ 
    public void done(ParseObject object, ParseException e){ 
        if (e == null){ 
        // object will be your game score 
        } else { 
        // something went wrong 
        } 
    } 
});

I am using Android Studio 1.0.1, and the error I am getting is:

Class 'Anonymous class derived from GetCallback' must be either be declared abstract or implement abstract method 'done(T,ParseException) in GetCallback

Any help or suggestions on how to solve this would be greatly appreciated, thanks.

EDIT:

Turns out it was just my database on Parse.com that was somehow corrupted... Creating a new database fixed it, for whatever reason. I do however have another problem. I can debug inside the done function, and the object contains all the information. However, I cannot extract it outside the done function. How is that done? Thanks.

2
What happens if you add @Override to the done method? - mkobit
Same error on GetCallback, but on @Override it says: Method does not override method from its superclass - David
What do you wanna debug in the done function , the object ?? - Kiloreux
No, I debugged in the done function to see if 'object' contained any information, which it did, however I want this information (or the object) outside of the done function. - David
My IDE didn't import com.parse.ParseException, which caused that same error to occur, hopefully this will help someone else - ElliotM

2 Answers

2
votes

I got the same error. In my case I auto imported wrong library:

import java.text.ParseException;

instead of

import com.parse.ParseException;

Just check your import.

0
votes

I don't think its possible. the done function is the callback method for when the query has been completed. If you debug your code you'll notice that it steps over the function because it is called asynchronously, meaning that the application wont wait for it to complete.

Once the query returns you are meant to check if there has been an error and then do whatever you need to once you have retrieved the parse object.