Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Share Intent chooser - Sharing TEXT with Facebook/Twitter Social media etc

If I only send text, the Share Intent chooser DOES NOT give Facebook/Twitter as an option.

Only Gmail, Skype and Evernote are options.

Here is my code

Intent shareIntent = new Intent(Intent.ACTION_SEND);

shareIntent.setType("plain/text");
shareIntent.putExtra(Intent.EXTRA_TEXT, text)
startActivity(Intent.createChooser(shareIntent, "Share using"));

I have tried different combination of setType() with no joy including "text/*", "text/html" and passing HTML text in the putExtra as follows:

shareIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("<p>This is the text that will be shared.</p>"));

When I use "text/plain", Facebook comes up as an option but the text does not load up when selecting it. But the text does load for Twitter,email, SMS.

Has anyone else encountered this problem?

When I share an image, there is no problem and Facebook along with other social media apps are available on the list.

like image 521
tiptopjat Avatar asked Jun 01 '12 22:06

tiptopjat


2 Answers

Also it should be "text/plain" and not "plain/text" according to the documentation.

like image 130
pedronveloso Avatar answered Nov 11 '22 10:11

pedronveloso


this depends upon what intent filters are defined by each of those apps.
For instance if I add intent-filter android.intent.action.send

If I choose single image from Gallery my application will appear in the list. However if I choose multiple my application will not appear as I have not added the intent-filer for android.intent.action.send_multiple

So it depends upon what intents facebook is filtering for. You need to see the release notes or help or developer pages for that.

like image 43
Orlymee Avatar answered Nov 11 '22 10:11

Orlymee