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 Creating the Message

Creating the Message Code Challenge

I'm trying to get the 1st part of this challenge to work. I have declared the new ParseObject as

ParseObject Event = new ParseObject();

below where it asks to place the code. It just tells me that I have compiler error.

8 Answers

The question asks you to define a ParseObject object with the class name parameter "Event", not an object instance named "Event.

Also, the ParseObject constructor requires a String parameter as the class name parameter. Hence you should define it something like this:

ParseObject someNameForTheInstance = new ParseObject( "Event" );
Paul Stevens
Paul Stevens
4,125 Points

Hello,

eventName is a string, not a variable and has to have quotation marks around it :

mEvent.put("eventName", "Birthday party");

That should sort it out.

You are right, Marc-Oliver, when you say: "This one seems tricky, indeed."

Personally I'm not seeing where "mEvent" is defined anywhere?!

The challenge says:

Challenge Task 2 of 3

Set the name of the event as "Birthday party". Use "eventName" as the key.

So I decided to go with (because it passed):

import android.app.Activity;
import com.parse.ParseObject;
import java.util.Date;
import java.util.GregorianCalendar;

public class MainActivity extends Activity {

    // Some code omitted!

    public void addNewEvent() {
        // param 1 = year, param 2 = month, param 3 = day
        Date date = new GregorianCalendar(2014, 0, 1).getTime(); 

        // Add code here!
        ParseObject event = new ParseObject("Event");
        event.put("eventName", "Birthday party");
        event.put("eventDate",date);
   }
}

Thank you very much John that helped out a lot. I do have a question on the second part of the challenge. I have put down

            <p>i
mport android.app.Activity;
import com.parse.ParseObject;
import java.util.Date;
import java.util.GregorianCalendar;

public class MainActivity extends Activity {

    // Some code omitted!

    public void addNewEvent() {
        // param 1 = year, param 2 = month, param 3 = day
        Date date = new GregorianCalendar(2014, 0, 1).getTime(); 

        // Add code here!
      ParseObject mEvent = new ParseObject( "Event" );
      mEvent.put(eventName, "Birthday party");
   }
}
</p>
            ``` 

but did doesn't seem to be working.
Marc-Oliver Gern
Marc-Oliver Gern
8,747 Points

This one seems tricky, indeed. I am stuck with task 3 as well.

Put the event name in double quotes "eventname"

Marc-Oliver Gern please try this

           import android.app.Activity;
           import com.parse.ParseObject;
           import java.util.Date;
           import java.util.GregorianCalendar;
           public class MainActivity extends Activity {
             // Some code omitted!
             public void addNewEvent() {
        // param 1 = year, param 2 = month, param 3 = day
        Date date = new GregorianCalendar(2014, 0, 1).getTime(); 
      //date.put("eventDate",(2014,0,1));
         ParseObject mEvent = new ParseObject( "Event" );
          mEvent.put("eventName", "Birthday party");
      mEvent.put("eventDate",date);
        // Add code here!
        }
     }

how did you guys come up with that code,i need ton understasnd thanx