how to share via email intent code example
Example: android mailto intent
class MailToExample{
private val url = "https://your_site_addres.xyz"
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_mailto)
val settings: WebSettings = mWebView.settings
settings.javaScriptEnabled = true
settings.allowFileAccess = true
mWebView.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, urlin: String?): Boolean {
if (urlin != null) {
if (urlin.contains("mailto:")) {
val emailIntent = Intent(Intent.ACTION_SENDTO, Uri.parse(urlin))
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "subject")
emailIntent.putExtra(Intent.EXTRA_TEXT, "body")
startActivity(Intent.createChooser(emailIntent, "Send email"))
} else {
view?.loadUrl(urlin)
}
}
return true
}
}
mWebView.postUrl(url)
}
}