5
Tôi muốn gửi nhiều tệp qua eMail. Tôi tìm thấy điều này Android multiple email attachments using Intent nhưng nó hoạt động và tôi không nhận được bất kỳ thông báo lỗi nào. Nó chỉ không đính kèm các tập tin (tôi cũng đã cố gắng để gửi chỉ một tập tin nhưng tôi đã nhận được kết quả tương tự).Mục đích Android: Gửi email có tệp đính kèm
Tôi đã giám sát điều gì đó chưa? Bạn có đề nghị nào không?
private static void email (Context context, String emailTo, String emailCC,
String subject, String emailText, List<String> filePaths)
{
//need to "send multiple" to get more than one attachment
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("text/xml");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{emailTo});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailText);
//has to be an ArrayList
ArrayList<Uri> uris = new ArrayList<Uri>();
//convert from paths to Android friendly Parcelable Uri's
for (String file : filePaths)
{
File fileIn = new File(file);
// Uri u = Uri.fromFile(fileIn);
Uri u = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "blabla.xml"));
Log.v("bla", "filepath: " +u.toString());
uris.add(u);
Uri b = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "blabla.es"));
uris.add(b);
Log.v("bla", "filepath: " +b.toString());
}
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
context.startActivity(emailIntent);
}
LogCat:
03-06 16:08:50.940: INFO/ActivityManager(69): Starting: Intent { act=android.intent.action.SEND_MULTIPLE typ=text/xml cmp=com.android.email/.activity.MessageCompose (has extras) } from pid 436
03-06 16:08:52.130: INFO/ActivityManager(69): Displayed com.android.email/.activity.MessageCompose: +1s118ms
03-06 16:08:52.470: WARN/IInputConnectionWrapper(436): showStatusIcon on inactive InputConnection
Rõ ràng, nhưng, bạn có chắc đường dẫn tệp của mình chính xác và trỏ đến tệp thực không? – dymmeh
đường dẫn tệp chính xác – user1252642
Hầu hết các chương trình email sẽ không thể xử lý các loại MIME văn bản/xml'. Hơn nữa, hầu hết người dùng không thể đọc XML. Vui lòng xem xét sử dụng văn bản email 'text/plain' hoặc' text/html' thay thế. – CommonsWare