Created
June 19, 2018 04:55
-
-
Save markcerqueira/b8b1d16afd0784dd889896e265245766 to your computer and use it in GitHub Desktop.
This file contains 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 attachmentUris = ArrayList<Uri>().apply { | |
add(FileProvider.getUriForFile(activity, "gg.mark.provider", File.createTempFile("gg", ".txt", context.cacheDir))) | |
add(FileProvider.getUriForFile(activity, "gg.mark.provider", File.createTempFile("hello", ".txt", context.cacheDir))) | |
} | |
val sendEmailIntent = Intent(Intent.ACTION_SEND_MULTIPLE).apply { | |
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | |
type = "text/plain" | |
// Needed to get file attachments working on older versions of Android | |
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) { | |
addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION) | |
} | |
putExtra(Intent.EXTRA_EMAIL, EMAIL_RECIPIENTS) | |
putExtra(Intent.EXTRA_SUBJECT, "With love from mark.gg") | |
putExtra(Intent.EXTRA_TEXT, "Be the change you want to see in the world.") | |
putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachmentUris) | |
} | |
activity.startActivity(sendEmailIntent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment