试图将SD卡上的文件附加到电子邮件中我正试图发起一个发送电子邮件的意图。所有这些都有效,但当我试图真正发送电子邮件时,会发生一些“奇怪”的事情。这是代码Intent sendIntent = new Intent(Intent.ACTION_SEND);sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Photo");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("
sendIntent.putExtra(Intent.EXTRA_TEXT, "Enjoy the photo");startActivity(Intent.createChooser(sendIntent, "Email:"));因此,如果我使用Gmail菜单上下文启动,它将显示附件,允许我键入电子邮件发送给谁,并编辑Body&Subject。别小题大作。我点击发送,它就发送。唯一的问题是附件没有发送。所以。我想,为什么不试试电子邮件菜单上下文(用于我手机上的备用电子邮件帐户)。它显示附件,但在正文或主题中根本没有文本。当我发送它时,附件发送正确。这会让我相信有些事很不对劲。我是否需要一个新的许可在宣言发布,意图发送电子邮件w/附件?我做错什么了?
3 回答
![?](http://img1.sycdn.imooc.com/54586653000151cd02200220-100-100.jpg)
守着一只汪
TA贡献1872条经验 获得超3个赞
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..."));
V/DumbDumpersMain( 3972): sPhotoUri=file://sdcard/DumbDumpers/DumbDumper.jpgI/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
更新
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://img1.sycdn.imooc.com/545861b80001d27c02200220-100-100.jpg)
慕码人2483693
TA贡献1860条经验 获得超9个赞
Intent i = new Intent(Intent.ACTION_SEND);i.putExtra(Intent.EXTRA_SUBJECT, "Title");i.putExtra(Intent.EXTRA_TEXT, "Content");i.putExtra(Intent.EXTRA_STREAM, uri);i.setType("text/plain");startActivity(Intent.createChooser(i, "Send mail"));
uri = Uri.fromFile(new File(context.getFilesDir(), FILENAME));
uri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), FILENAME));
![?](http://img1.sycdn.imooc.com/533e4c5600017c5b02010200-100-100.jpg)
ABOUTYOU
TA贡献1812条经验 获得超5个赞
- 3 回答
- 0 关注
- 534 浏览
添加回答
举报
0/150
提交
取消