我正在尝试使用intent发送带附件的电子邮件。 该文件是存储在原始文件夹中的pdf。它不到200k。 但它显示的文件太大而无法附加。 Y' 帮帮我..
Intent in = new Intent(Intent.ACTION_SEND);
in.setType("application/pdf");
in.putExtra(Intent.EXTRA_EMAIL,new String[]{email.getText().toString()});
in.putExtra(Intent.EXTRA_SUBJECT, "Android Development Course");
Uri uri = Uri.parse("android.resource://deepak.android.samples/raw/android");
in.putExtra(Intent.EXTRA_STREAM,uri);
startActivity(Intent.createChooser(in, "Sending email.."));
答案 0 :(得分:4)
使用此方法
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{"emailaddress"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Body");
String rawFolderPath = "android.resource://" + getPackageName()
+ "/" + R.raw.shortcuts;
// Here my file name is shortcuts.pdf which i have stored in /res/raw folder
Uri emailUri = Uri.parse(rawFolderPath );
emailIntent.putExtra(Intent.EXTRA_STREAM, emailUri);
emailIntent.setType("application/pdf");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));