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 trialMUZ140820 Immaculate Ncube
4,611 Pointsi need help with this part of my code
Inside the done() method of the callback, add an if statement to check if the ParseException e is null. If it is not null, log the message "ERROR" using the Log.e() method. Donβt forget to use TAG as the first parameter!
import android.app.Activity;
import android.util.Log;
import com.parse.ParseUser;
import com.parse.ParseException;
import com.parse.SignUpCallback;
public class SignUpActivity extends Activity {
public static final String TAG = SignUpActivity.class.getSimpleName();
protected SignUpCallback mSignUpCallback = new SignUpCallback() {
@Override
public void done(ParseException e) {
}
};
// onCreate() and other code has been omitted
protected void signUp(String username, String password) {
ParseUser newUser = new ParseUser();
newUser.setUsername(username);
newUser.setPassword(password);
newUser.signUpInBackground(new SignUpCallback(){
});
}
}
1 Answer
Steve Hunter
57,712 PointsHi there,
Two things on this.
First, you've not used the callback that has already been set up for you. So if you change:
newUser.signUpInBackground(new SignUpCallback(){
});
to this:
newUser.signUpInBackground(mSignUpCallback);
that uses the variable that has already been created. Then you need to check for the error in the done
method.
You can use an if statement to test that. So, " if the error variable contains nothing, great!, else, log the error. That looks like:
public void done(ParseException e) {
if(e == null){
// success!
} else {
Log.e(TAG, "ERROR");
}
}
I hope that helps.
Steve.