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 trialAntonis Tsagaris
17,511 PointsIntent.createChooser() returns an error
I cannot complete the Code Challenge because the compiler gives me an error at the dot between "Intent" and "createChooser". I'm pretty sure that I'm doing everything right. Any ideas?
3 Answers
Javier Briones
Front End Web Development Techdegree Student 29,674 PointsI figured it out. Here's my working code:
startActivity(Intent.createChooser(shareIntent, getString(R.string.choose_title));
You have to use the 'getString' method to get the string from 'R.string.choose_title'
Hiroki Hokari
5,308 PointsCould you post the code including the error part?
Antonis Tsagaris
17,511 PointsIntent inte = new Intent(Intent.ACTION_SEND); inte.setType("text/plain"); inte.putExtra(Intent.EXTRA_TEXT, "extra text"); startActivity(Intent.createChooser(inte, R.string.chooser_title));
Fixed though - Xavier found the solution.
Javier Briones
Front End Web Development Techdegree Student 29,674 PointsI'm having the same problem too
Antonis Tsagaris
17,511 PointsAntonis Tsagaris
17,511 PointsThanks. Weirdly, during the tutorial the code seemed to work fine without the getString() method.