也越来越相同的问题
代码:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("image/jpeg");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]
{"[email protected]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"go on read the emails");
Log.v(getClass().getSimpleName(), "sPhotoUri=" + Uri.parse("file:/"+ sPhotoFileName));
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:/"+ sPhotoFileName));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
从亚行logcat:
V/DumbDumpersMain(3972): sPhotoUri=file://sdcard/DumbDumpers/DumbDumper.jpg
I/ActivityManager( 56): Starting activity: Intent { action=android.intent.action.CHOOSER comp={android/com.android.internal.app.ChooserActivity} (has extras) }
I/ActivityManager( 56): Starting activity: Intent { action=android.intent.action.SEND type=jpeg/image flags=0x3000000 comp={com.google.android.gm/com.google.android.gm.ComposeActivityGmail} (has extras) }
I/ActivityManager( 56): Starting activity: Intent { action=android.intent.action.SEND type=jpeg/image flags=0x2800000 comp={com.google.android.gm/com.google.android.gm.ComposeActivity} (has extras) }
D/gmail-ls( 120): MailProvider.query: content://gmail-ls/labels/[email protected](null, null)
D/Gmail (2507): URI FOUND:file://sdcard/DumbDumpers/DumbDumper.jpg
看起来电子邮件提供商正在附加一个长度为0的文件。当我检查文件系统时,文件存在且正确。创建图像文件的代码在尝试发送电子邮件之前已经完成。
任何人修复这个没有魔术重启(我已经试过了)?
更新我
路径应该是
file:///sdcard/DumbDumpers/DumbDumper.jpg
你需要额外的/因为这点到根目录下,即:
file:// + /sdcard/DumbDumpers/DumbDumper.jpg
合并为
file:///sdcard/DumbDumpers/DumbDumper.jpg
在上面的代码中,你需要:
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ sPhotoFileName));
我希望这有助于。我花了很多时间去调试。
看这它可以帮助你解决你的问题。 http://stackoverflow.com/questions/2518055/image-attachment-to-a-mail-how-in-android –