android - 如何将 Html 文本共享到 whatsapp Intent

标签 android android-intent whatsapp

我想通过 whatsapp intent 分享 Html 文本。我写的代码如下。

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                sharingIntent.setType("text/html");
                sharingIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(new StringBuilder()
                .append("<p><b>Some Content</b></p>")
                .append("<small><p>More content</p></small>")
                .toString()));
                this.getContext().startActivity(Intent.createChooser(sharingIntent,"Share using"));

但 whatsapp 应用程序未显示在 Intent 选择器列表中。

谁能给我建议解决方案?

最佳答案

试试这个

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setPackage(com.whatsapp);
sendIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(new StringBuilder()
    .append("<p><b>Some Content</b></p>")
    .append("<small><p>More content</p></small>")
    .toString()));
sendIntent.setType("text/html");
context.startActivity(sendIntent);

关于android - 如何将 Html 文本共享到 whatsapp Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36076067/

相关文章:

android - 从浏览器链接启动 android 应用程序

Android GET_CONTENT 音频文件

javascript - 是否可以检测是否安装了whatsapp?

android - 错误 :Program type already present: android. arch.lifecycle.LiveData

android - 自定义属性 - 方向变化

android - OnResume 之后立即调用 OnPause

android - 如何查看我的通讯录中的号码是否已注册到 Whatsapp?

ios - 选择 WhatsApp 后从 UIActivityViewController 中删除事件项目

android - 使用 nrf52840-Dongle 和 Android Things 创建 LowPAN 网络

c# - Android 设备上的表面光闪烁