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
Nanette Keir
17,666 PointsLast Code Challenge for Blog Reader
I am almost done with Android Blog Reader (yea!!) but I am stuck on the last code challenge. The error message I get is:
Bummer! Compilation Error! This is tricky task! Check your syntax and make sure you're calling 'startActivity()', 'createChooser()', and 'getString()' correctly.
Sure is tricky task! I keep thinking that R.string.chooser_title should be R.string.chooser_text instead but that wouldn't make sense since string.chooser is looking towards EXTRA_TEXT, "HOWDY". I've also considered getString.Extra but again I get the same error.
I know I'm doing something wrong but not too sure what.
Thanks in advance!
/* This code is an excerpt from the onOptionsItemSelected()
* method of a custom Activity class.
*/
int itemId = item.getItemId();
if (itemId == R.id.action_share) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, "HOWDY");
startActivity(Intent.createChooser(getString, R.string.chooser_title));
}
2 Answers
Ben Jakuben
Treehouse TeacherSo close! You have the correct basic structure with startActivity and the Intent.createChooser() method. But the parameters for the createChooser() method aren't quite right. The first parameter should be the Intent you created earlier in the challenge. And the second parameter is a call to the getString() method. The getString() method takes R.string.chooser_title as its parameter, but your code isn't calling getString as a method nor passing it the parameter.
Hope this helps! Let me know if this isn't enough information or doesn't make sense.
Nanette Keir
17,666 PointsYes! That does help!! I also re-watched your video and then hit myself on the forehead! Thanks so much for all your help!!
Nanette Keir
17,666 PointsHi Ronny, Really close!! I think you don't need "share_" towards the end. If you take out that you should be fine.
Ronny Perez
29,956 PointsRonny Perez
29,956 PointsHey Ben can you please tell me what I'm doing wrong
Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, "hfgrg"); startActivity(Intent.createChooser(shareIntent, getString(R.string.share_chooser_title)));