Namaste 🙏 to all,
I am trying to achieve a solution where on click of email id in strings XML containing HTML tags we should open Intent Chooser of email apps available in the system, then in the email compose screen mailTo, subject & the body should be populated.
to - [email protected] subject - xyz.... body - xyz.....
I have tried using android:autoLink="email"
attribute, it is making the email clickable but it only pre-populates the recipient's email id and nothing else.
Is there any other way around to achieve the required solution, without using a third-party library?
Namaste 🙏 to all,
Below is the working solution, without using the android:autoLink="email"
attribute.
strings.xml
<string name="str_email_included">Mail us at - <br/> <a href=\'mailto:[email protected]?subject=Subject1&body=Body1\'>[email protected]</a></string>
Java
textView.setText(Html.fromHtml(getString(R.string.str_email_included))); textView.setMovementMethod(LinkMovementMethod.getInstance());
Kotlin
textView.text = HtmlCompat.fromHtml(getString(R.string.str_email_included), HtmlCompat.FROM_HTML_MODE_LEGACY) textView.movementMethod = LinkMovementMethod.getInstance()
The above movementMethod
does the job, so onClick of email id, Intent Chooser will open and the mailTo, subject & body get pre-populated as required.