我正在开发一个Android应用程序,并希望通过打开
设备中可用的所有共享选项来共享一些文本.但目前该列表显示的是电子邮件,蓝牙,Gmail和消息.
其他应用如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"));
Run Code Online (Sandbox Code Playgroud)
在清单中
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)