我有这封电子邮件发送的代码没有显示选择器(好)。如何扩展它以包含文件附件,而不涉及选择器?
// Based on http://stackoverflow.com/questions/3312438
final Intent intent = new Intent(Intent.ACTION_VIEW);
final Uri data = Uri.parse("mailto:user@domain.com?subject=My Sugbject&body=");
intent.setData(data);
startActivity(intent);
答案 0 :(得分:0)
尝试以下代码,
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("image/jpg");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("photo.jpg"));
startActivity(i);
答案 1 :(得分:0)
试试这个:
Intent emailintent = new Intent(android.content.Intent.ACTION_SEND);
emailintent.setType("image/jpeg");
emailintent.putExtra(android.content.Intent.EXTRA_TEXT,
"email body here");
emailintent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]
{"test@gmail.com"});
emailintent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Subject here");
String filName="file:///sdcard/photos/estdemo.jpg";
emailintent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:/"+ filName));
this.startActivity(emailintent);
答案 2 :(得分:0)
使用以下代码发送邮件
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("vnd.android.cursor.dir/email");
String to[] = "asd@gmail.com";
sharingIntent.putExtra(Intent.EXTRA_EMAIL, to);
sharingIntent.putExtra(Intent.EXTRA_STREAM,filePath);
sharingIntent.putExtra(Intent.EXTRA_SUBJECT,"subject");
startActivity(Intent.createChooser(sharingIntent, "Send email"));