I have an activity that launches the email intent, passing an array list of Uri objects, that point to local files. This works when there are a small number of files e.g. 3, or 10. However when i have 1000+ files (totalling a size of 14 mb), the activity hangs (which is expected, lots of i/o), however it sometimes hangs indefinitely or when it does return the intent doesn't launch.
Below code (called by an AsyncTask) creates the array list of Uri's and launches Email intent:
private Intent createEmailAndSend(List<FilePath> paths) {
Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("message/rfc822");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Email subject");
ArrayList<Uri> fileUriList = new ArrayList<>();
for (FilePath filePath : paths) {
File file = new File(filePath.getPath());
fileUriList.add(Uri.fromFile(file));
}
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, fileUriList);
startActivity(intent);
}
Testing on:
- Genymotion, Android Studio 2 Beta Emulator, Nexus 7 and Nexus 6p
- Android: Minimum 19 (Kitkat) and target is Kitkat
Does anyone know what i'm doing wrong?