I tried to share a multi-line text using the following code, but only the last line appears.
val sharingIntent = Intent(Intent.ACTION_SEND)
sharingIntent.setType("text/plain")
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Found this cool deal! Check it out.")
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, TITLE)
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "MRP : $PRICE")
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Deal Price : $DEAL_PRICE")
startActivity(Intent.createChooser(sharingIntent, "Share using"))
When you call putExtra(key, value)
, any value previous put under the same key
gets wiped out. Try putting a single string that contains all the text you want:
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"Found this cool deal! Check it out.\n" +
TITLE + "\n" +
"MRP : $PRICE\n" +
"DEAL PRICE : $DEAL_PRICE");
As for the HTML content, you'll need to show us the code you used. However, you probably don't want to use fromHtml()
; that converts HTML to styled text, which I suspect is not what WhatsApp expects to receive. Try just sending the raw HTML with the correct MIME type.