2012-07-04 19 views
2

我正在开发一个Android应用程序,并希望通过打开设备中可用的所有
共享选项来共享一些文本。但目前该列表正在显示电子邮件,蓝牙,Gmail和消息。如何显示android中的所有共享选项?

像BBC新闻这样的其他应用在Bump,Picasa和其他应用中显示更多选项。如何显示所有可用的选项并处理它们?

我使用这个:

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")); 

和清单

<intent-filter> 
    <action android:name="android.intent.action.SEND" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <data android:mimeType="text/plain"/> 
    </intent-filter> 
+0

如果没有得到解决,那么使用''而不是''这会显示所有选项,包括Bump,Picasa –

回答

6

这是因为你只显示而是使用注册为处理text/vcard意图

sharingIntent.setType("text/plain"); 
+0

谢谢巴迪......欢呼声...... – AndDev21

+0

经过bluttoth或短信或任何东西分享后,它给了我黑色屏幕如何克服这一点,使它把我带到我以前的屏幕 – AndDev21

1
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")); 
+0

@ AndDev21高兴地帮助,如果这个答案帮助你,那么请将它标记为已接受,这样也可以帮助其他人。享受编码。 –

0

仅供分享文字使用 sharingIntent.setType(“text/plain”); 并为sgaring图像使用 sharingIntent.setType(“image/*”);

相关问题