问题
I am developing an Android app and want to share some text by opening all the
share options available in device. But currently the list is showing Email, bluetooth, Gmail and messaging.
Other apps like BBC news are showing more options in the same device like Bump, Picasa, and others. How to show all available options and handle them?
I am using this:
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/vcard");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,mailBody);
startActivity(Intent.createChooser(sharingIntent,"Share using"));
and in manifest
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain"/>
</intent-filter>
回答1:
It is because you're only showing intents registered to handle text/vcard
Instead use
sharingIntent.setType("text/plain");
回答2:
Intent i=new Intent(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(android.content.Intent.EXTRA_SUBJECT,"Subject test");
i.putExtra(android.content.Intent.EXTRA_TEXT, "extra text that you want to put");
startActivity(Intent.createChooser(i,"Share via"));
回答3:
for sharing text only use sharingIntent.setType("text/plain"); And for sgaring image Use sharingIntent.setType("image/*");
来源:https://stackoverflow.com/questions/11329851/how-to-show-all-share-options-in-android