【问题标题】:Android - Chooser dialog for sharing -- different intents depending on application selected?Android - 用于共享的选择器对话框 - 不同的意图取决于所选的应用程序?
【发布时间】:2015-10-13 18:42:16
【问题描述】:

我想根据用户选择的应用程序共享不同的信息。例如,我想向 Twitter 发送比 Gmail 更短的文本(否则,我会使用字符)。有没有办法做到这一点?额外的问题,是否可以通过 Gmail 或 SMS 共享来制作超链接。例如,“下载这里”,其中“这里”是一个链接,而不是“点击下面的链接下载: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"));

【问题讨论】:

    标签: android android-intent sharing


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      使用下面的代码可以帮助你:

      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)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-11
        • 2016-03-04
        相关资源
        最近更新 更多