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

Android Build a Blog Reader Android App Using Intents to Display and Share Posts Easy Sharing with Intents

Antonis Tsagaris
Antonis Tsagaris
17,511 Points

Intent.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
seal-mask
.a{fill-rule:evenodd;}techdegree
Javier Briones
Front End Web Development Techdegree Student 29,674 Points

I 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'

Antonis Tsagaris
Antonis Tsagaris
17,511 Points

Thanks. Weirdly, during the tutorial the code seemed to work fine without the getString() method.

Could you post the code including the error part?

Antonis Tsagaris
Antonis Tsagaris
17,511 Points

Intent 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.