我想通过 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/