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 trialRicky Sparks
22,249 PointsMy Java code for Message-Destruction App won't pass?
The code below is excerpted from the finished Ribbit app. There are two errors in it: find and fix them! Read line by line, even character by character if you have to.
Charles Welbeck
Courses Plus Student 9,745 PointsRicky did you get this figured out?
Ricky Sparks
22,249 PointsYes thanks for asking :D
4 Answers
james white
78,399 PointsThis is actually not called the "My Java" challenge, but the "Introducing the Project" challenge: http://teamtreehouse.com/library/introducing-the-project-2
The starting (given) warmup.java code was:
Intent recipientsIntent = new Intent(this, RecipientsActivity.class)
recipientsIntent.setData(mMediaUri); // mMediaUri is defined and set elsewhere
recipientsIntent.putExtra("file_type", "image");
startActivity(thisIsTheWrongIntent);
You'll notice that Ricky correctly got the first edit in his posted code above by adding a semi-colon to the end of the first line:
Intent recipientsIntent = new Intent(this, RecipientsActivity.class);
Daniel then provided the needed adjustment to the last line.
However I looked up the github version of this code here: https://github.com/treehouse/android-ribbit/blob/master/src/com/teamtreehouse/ribbit/MainActivity.java
Here is the chunk of code that was excerpted:
Intent recipientsIntent = new Intent(this, RecipientsActivity.class);
recipientsIntent.setData(mMediaUri);String fileType;
if (requestCode == PICK_PHOTO_REQUEST || requestCode == TAKE_PHOTO_REQUEST) {
fileType = ParseConstants.TYPE_IMAGE;
}
else {
fileType = ParseConstants.TYPE_VIDEO;
}
recipientsIntent.putExtra(ParseConstants.KEY_FILE_TYPE, fileType);
startActivity(recipientsIntent);
You'll notice that the third line reads not:
recipientsIntent.putExtra("file_type", "image");
but this line instead:
recipientsIntent.putExtra(ParseConstants.KEY_FILE_TYPE, fileType);
However, taking the time to look up the actual code won't help you because this actually (real) MainActivity.java code will not pass the challenge test.
So I really don't know what the purpose of this challenge was/is...?
Ricky Sparks
22,249 PointsThanks guys :D
Daniel Hartin
18,106 PointsHi Ricky
I think the intent variable is named recipientsIntent not simply intent
startActivity(recipentsIntent);
Hope this helps
Daniel
Charles Welbeck
Courses Plus Student 9,745 Points// The code below is an excerpt from this finished app
Intent recipientsIntent = new Intent(this, RecipientsActivity.class);
recipientsIntent.setData(mMediaUri); // mMediaUri is defined and set elsewhere
recipientsIntent.putExtra("file_type", "image");
startActivity(recipentsIntent);
Joe Goodall
3,483 PointsSorry to be pedantic but there is an 'i' missing from the last line.
Should read startActivity(recipientsIntent); rather than startActivity(recipentsIntent);.
Emmanuel Niyenzima
2,711 Points// The code below is an excerpt from this finished app
Intent recipientsIntent = new Intent(this, RecipientsActivity.class); recipientsIntent.setData(mMediaUri); // mMediaUri is defined and set elsewhere recipientsIntent.putExtra("file_type", "image"); startActivity( recipientsIntent);
TheBigoso /\
3,217 PointsIntent recipientsIntent = new Intent(this, RecipientsActivity.class); recipientsIntent.setData(mMediaUri); // mMediaUri is defined and set elsewhere recipientsIntent.putExtra("file_type", "image"); startActivity( recipientsIntent);
Ricky Sparks
22,249 PointsRicky Sparks
22,249 PointsIntent recipientsIntent = new Intent(this, RecipientsActivity.class); recipientsIntent.setData(mMediaUri); // mMediaUri is defined and set elsewhere recipientsIntent.putExtra("file_type", "image"); startActivity(Intent);