How to show all share options in android?

陌路散爱 提交于 2020-01-02 07:42:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!