Issue
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));
Solution
Well, it is definitely an Emulator issue.
I installed intel's HAXM VM and created a new AVD with intel image and, not only it runs faster, but it sent the mails, attachments included, without problem instantly.
Edit
I found out, when tested on a real device that it is a real problem, this post is very helpful
Answered By - ilomambo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.