I am sending a mail with logs results through this code:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailAddressList);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Android Log");
emailIntent.putParcelableArrayListExtra(android.content.Intent.EXTRA_STREAM, uris);
try {
startActivity(Intent.createChooser(emailIntent,"Send..."));
finish();
}
catch (android.content.ActivityNotFoundException e) {
new AlertDialog.Builder(SendActivity.this)
.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(R.string.cannotSend)
.setMessage(R.string.appNotFound)
.setPositiveButton(R.string.ok, null)
.show();
}
The Email app in the emulator (trget Jelly Bean) is this one:
When sending it shows this, which has the destination, the subject and the attachments:
The oubox shows the message has attachments:
But the received message has no attachmetns ar all:
My only guess is that the Email app has failed, but I don't know if it is my fault, and if I can correct it, or if there is another mail client I can install in the AVD who will do the job.
PS: By the way, sending those mails went really slow on the AVD, when I tested to compose and send a text only mail it was dispatched much more quickly.
Edit
I had an idea, could it be that the problem is caused because the attachements are from temporary files? And they are linked to the mail rather than copied, and by the time the Email app gets to send them, they no longer exists?
attachment = File.createTempFile("logs", "txt");
out = new FileOutputStream(attachment);
out.write(logs.getBytes());
out.close();
uris.add(Uri.fromFile(attachment));
attachment = File.createTempFile("sysinfo", "txt");
out = new FileOutputStream(attachment);
out.write(getSystemInfo());
out.close();
uris.add(Uri.fromFile(attachment));