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

My shareIntent on Blog Reader is not working :(

Hey guys,

My shareIntent is not working (for sharing my blog posts) :( , I've tried multiple code on the android documentation... I am able to click the share button, but when I do nothing happens.

Here is the code, let me know if I botched something up please:

public boolean OnOptionsItemSelected (MenuItem item) {
        int itemId = item.getItemId();

        if (itemId == R.id.action_share){
            sharePost();
        }

        return super.onOptionsItemSelected(item);
    }

    private void sharePost() {
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_TEXT, mUrl);
        startActivity(Intent.createChooser(shareIntent, getString(R.string.share_chooser_title)));
    }
Ratik Sharma
Ratik Sharma
32,885 Points

Looks fine to me. What exactly happens when you click the share button?