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

Share Intent

post.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                Intent shareIntent = new Intent();
                shareIntent.setAction(Intent.ACTION_SEND);
                shareIntent.setType("text/plain");
                shareIntent.putExtra(Intent.EXTRA_TEXT, text.getText()
                        .toString());

                startActivity(Intent.createChooser(shareIntent,
                        "Where do you want to share?"));
            }
        });

How do I make it available to some specific apps only?

2 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

As far as I know, it's not exactly easy to filter for specific apps. Here's one possible solution from StackOverflow: http://stackoverflow.com/a/18068122/475217

Thanks I'll have a look at it