Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Self-Destructing Message Android App Sending Messages Sending the Message

Finally, save this ParseObject in the background and pass in the mSaveCallback member variable.

May u please help ,me i am stuck.

MainActivity.java
import android.app.Activity;
import android.widget.EditText;
import android.widget.Toast;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.SaveCallback;

public class MainActivity extends Activity {

    protected EditText mDescriptionField;

    protected SaveCallback mSaveCallback = new SaveCallback() {
        @Override
        public void done(ParseException e) {
            Toast.makeText(MainActivity.this, "Item saved!", Toast.LENGTH_SHORT).show();
        }
    };

    // Some code omitted!

    public void save() {
      ParseObject mTask .new ParseObject("Task");
      // parseObject.saveInBackground(mSaveCallbck); // duplicate code? 
      String description = mDescriptionField.getText().toString();
      mTask.put("description", description);
      mTask.saveInBackground(mSaveCallbck);  // this is correct but the callback is called mSaveCallback


    }
}

1 Answer

Harry James
Harry James
14,780 Points

Hey there!

You were close! There's just a few typos in your code:

ParseObject mTask .new ParseObject("Task");
// You used a . instead of an = here!

parseObject.saveInBackground(mSaveCallbck); 
// You don't need to save in background yet - delete this on the second line of the save() method.

mTask.saveInBackground(mSaveCallbck);
// Here, mSaveCallbck should be mSaveCallback

These should be all of the issues you had and you should be able to pass the challenge. Hope it helps and if there's anything else, give me a shout :)

Thank u so much.I did not even realise i wrote Callbck instead of Callback until u pointed it out.lol

Harry James
Harry James
14,780 Points

Haha! Glad to hear you got passed the challenge then :)