且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

尝试从SD卡上的文件,电子邮件

更新时间:2023-09-27 23:11:22

也越来越相同的问题

code:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
    emailIntent.setType("image/jpeg");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] 
    {"me@gmail.com"}); 
    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:

From adb 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/me@gmail.com(null, null)
D/Gmail   ( 2507):      URI FOUND:file://sdcard/DumbDumpers/DumbDumper.jpg

看起来像电子邮件提供商附加0长度的文件。当我检查文件系统的文件是存在的,正确的。在code的创建图像文件以及之前以电子邮件的念头完成。

Looks like the email provider is attaching a 0 length file. When I check the filesystem the file is there and correct. The code which creates the image file is well finished prior to the attempt to email it.

任何人都解决了这个问题不用魔法重启(我已经试过了)?

Anyone fixed this without magic reboots (I've already tried that)?

问候,
散热片

Regards,
Fin

更新

路径对我来说应该是

文件:///sdcard/DumbDumpers/DumbDumper.jpg

您需要额外的 / ,因为这指向的根目录,即:

you need the extra / as this points to the root directory, i.e.:

文件:// + /sdcard/DumbDumpers/DumbDumper.jpg

组合成

文件:///sdcard/DumbDumpers/DumbDumper.jpg

在上面的代码中,你需要:

In the above snippet you need:

emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ sPhotoFileName));

我希望这有助于。我花了年龄调试。

I hope this helps. It took me ages to debug.

问候,
芬利