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 trialJavier Briones
Front End Web Development Techdegree Student 29,674 PointsHelp
I can't figure what's wrong with my solution. Here's my code
if(itemId == R.id.action_share)
{
// Add code here!
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
String Hello = "Hello";
shareIntent.putExtra(Intent.EXTRA_TEXT, Hello);
startActivity(Intent.createChooser(shareIntent, R.string.chooser_title));
}
And here's the error I get:
JavaTester.java:58: cannot find symbol
symbol : method createChooser(android.content.Intent,int)
location: class android.content.Intent
startActivity(Intent.createChooser(shareIntent, R.string.chooser_title));
^
1 error
I still don't understand what is wrong with my code
2 Answers
Ben Jakuben
Treehouse TeacherYou need to pass in an actual String as the 2nd parameter, not just the string ID:
startActivity(Intent.createChooser(shareIntent, getString(R.string.chooser_title)));
It's not totally clear, but the error message helps track this down:
symbol : method createChooser(android.content.Intent,int)
It's saying that it can't find a createChooser()
method that has an "int" as the 2nd parameter.