Created
June 1, 2023 10:45
-
-
Save jack-webb/42842dc0eff63bf8b6440e9a9778c976 to your computer and use it in GitHub Desktop.
An intent for sending plain text in an email
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val message = "Hello world!" | |
val emailSelectorIntent = Intent(Intent.ACTION_SENDTO).apply { | |
setData(Uri.parse("mailto:")) | |
} | |
val targetIntent = Intent(Intent.ACTION_SEND).apply { | |
putExtra(Intent.EXTRA_TEXT, message) | |
type = "text/plain" | |
} | |
targetIntent.selector = emailSelectorIntent | |
startActivity(targetIntent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment