Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
Add Comment
Please, Sign In to add comment