Android – how to share HTML text to WhatsApp
•
Android
I want to share HTML text through WhatsApp. The code I write is as follows
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"));
However, the WhatsApp application is not displayed in the intent selector list
Who can suggest my solution?
resolvent:
Try this
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);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码