0
fun shareProduct(context: Context) {
    Intent(Intent.ACTION_SEND).apply {
        type = "text/html"
        putExtra(Intent.EXTRA_SUBJECT, "Test")
        putExtra(
            Intent.EXTRA_TEXT,
            fromHtml("Visit <a href=\"https://www.google.com\">google</a> for more info.")
        )
        try {
            context.startActivity(
                Intent.createChooser(this, "Share")
            )
        } catch (e: Throwable) {
            e.printStackTrace()
        }
    }
}

private fun fromHtml(text: String): Spanned {
    return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        Html.fromHtml(
            text,
            Html.FROM_HTML_MODE_COMPACT
        )
    } else {
        @Suppress("DEPRECATION")
        Html.fromHtml(text)
    }
}

Chooser looks ok (we can see the text link):

enter image description here

But Gmail app doesn't have any link:

enter image description here

user924
  • 8,146
  • 7
  • 57
  • 139

0 Answers0