我正在尝试将我的 res/drawable 文件夹中的 png 文件作为电子邮件的附件发送。我可以将文件附加并包含在电子邮件中,但它缺少 .png 文件扩展名。我希望它在文件名中包含扩展名。有人可以帮忙吗?这是我的代码:
Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_SUBJECT, "Subject");
i.putExtra(Intent.EXTRA_TEXT , "Text");
ArrayList<Uri> uris = new ArrayList<Uri>();
Uri path = Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.png_image);
uris.add(newPath);
i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(ShareActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}