问题
I want to share Html
text via whatsapp intent
. The code I have written is below.
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"));
But whatsapp application is not showing in Intent chooser list.
Can anyone suggest me the solution?
回答1:
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);
回答2:
please change this in your code and let me know if it helped you,
sendIntent.setType("*/*");
来源:https://stackoverflow.com/questions/36076067/how-to-share-html-text-to-whatsapp-intent