Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.