Guest User

Untitled

a guest
Jun 20th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. val attachmentUris = ArrayList<Uri>().apply {
  2. add(FileProvider.getUriForFile(activity, "gg.mark.provider", File.createTempFile("gg", ".txt", context.cacheDir)))
  3. add(FileProvider.getUriForFile(activity, "gg.mark.provider", File.createTempFile("hello", ".txt", context.cacheDir)))
  4. }
  5.  
  6. val sendEmailIntent = Intent(Intent.ACTION_SEND_MULTIPLE).apply {
  7. addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
  8.  
  9. type = "text/plain"
  10.  
  11. // Needed to get file attachments working on older versions of Android
  12. if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
  13. addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION)
  14. }
  15.  
  16. putExtra(Intent.EXTRA_EMAIL, EMAIL_RECIPIENTS)
  17. putExtra(Intent.EXTRA_SUBJECT, "With love from mark.gg")
  18. putExtra(Intent.EXTRA_TEXT, "Be the change you want to see in the world.")
  19. putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachmentUris)
  20. }
  21.  
  22. activity.startActivity(sendEmailIntent)
Add Comment
Please, Sign In to add comment