Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Relating Users in Parse.com Executing a Query

alex gwartney
alex gwartney
8,849 Points

Not sure were to place the find in background?

So im really lost on these instructions because of the way this is set up. It wants me to pass in the find in background call back after the find call back? can some one take a look and explain to me what they are wanting

CodeChallenge.java
// This code is an excerpt from an Activity. Some code has been omitted!


 FindCallback<ParseUser> mFindCallback = new FindCallback<ParseUser>() {
    @Override
    public void done(List<ParseUser> users, ParseException e) {
        if (e == null) {

        }
    }
};

ParseQuery<ParseUser> query = ParseUser.getQuery();
query.orderByAscending("email");
alex gwartney
alex gwartney
8,849 Points

the quiz seems to be backwards to what is taught in the video?

1 Answer

Seth Kroger
Seth Kroger
56,414 Points

There are different styles of creating the callback. In the video, you write the callback as an anonymous inner class inside the function itself.

query.findInBackground(new FindCallback<ParseUser>() {
    @Override
    public void done(List<ParseUser> users, ParseException e) {
        if (e == null) {
           // Do something here...
        }
    });

However that new FindCallback<ParseUser>() {} can be stored in a variable as well which can then be used in the findInBackground(). This other style is what the challenge uses. If you have more than one findInBackground() call in you code that uses the same callback code, you can simply reference the variable instead of rewriting the callback every time.

alex gwartney
alex gwartney
8,849 Points

I figured it out thanks for the explanation i was looking at in the wrong way.