Android share intent with html text
The following will launch a bottom sheet with a list of apps and let you pick an app to share the content. For example, if you picked an email app, it will populate the subject and body in that email app. The example text here contains html tags, by setting the type to “text/html”, and parse the html content using HtmlCompat.fromHtml
, it will renders the html in the email app or any other app that can handle html contents.
val shareIntent = Intent(android.content.Intent.ACTION_SEND) shareIntent.type = "text/html" shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Android Notification") shareIntent.putExtra(Intent.EXTRA_TEXT, HtmlCompat.fromHtml("Title
This is a body
", HtmlCompat.FROM_HTML_MODE_LEGACY)) startActivity(Intent.createChooser(shareIntent, "Share with:"))
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts