Android - 用于共享的选择器对话框 - 根据所选应用程序的不同意图?

时间:2015-10-13 18:42:16

标签: android android-intent sharing

我想根据用户选择的应用程序分享不同的信息。例如,我想向Twitter发送短文本而不是Gmail(否则,我会用字符表示)。反正有没有实现这个目标?奖金问题,是否可以通过Gmail或短信分享超链接。例如,“在此处下载 ”,其中“here”是链接,而不是“通过点击以下链接下载:http:// ...”

当前代码:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, getTextToShare(data));
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, data.getTitle());
startActivity(Intent.createChooser(shareIntent, "Share this story"));

2 个答案:

答案 0 :(得分:0)

要查找所选的共享目标,您可能会感兴趣:Branching the Android Share Intent extras depending on which method they choose to share

答案 1 :(得分:0)

使用以下代码可以帮助您:

String shareText="Download <a href='[download link]'>here</a>";
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, Html.toHtml(shareText));
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, data.getTitle());
startActivity(Intent.createChooser(shareIntent, "Share this story"));

Share Url Links and Texts into Social Networks (Facebook,Twitter and linkedin)

相关问题