我正在尝试将SD卡中的图像附加到电子邮件中(从我的应用程序附加到Gmail应用程序)。
每次尝试时,我都会选择Gmail应用并关闭,但不会附加该文件。
假设图像路径为:/sdcard/DCIM/Snapseed/Snapseed4.jpg
。这是我用来发送电子邮件的代码:
Intent emailintent2 = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailintent2.setType("image/*");
emailintent2.putExtra(Intent.EXTRA_EMAIL, emailaddress2);
emailintent2.putExtra(Intent.EXTRA_SUBJECT, CorAsunto);
emailintent2.putExtra(Intent.EXTRA_TEXT, message2);
Uri uris = Uri.fromFile(new File(Environment.getExternalStorageDirectory()
+ "/DCIM/Snapseed/Snapseed4.jpg"));
emailintent2.putExtra(Intent.EXTRA_STREAM, uris);
startActivity(emailintent2);
答案 0 :(得分:0)
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
emailIntent.setType("image/jpeg");
emailIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("SDCARD IMAGE PATH"));
startActivity(Intent.createChooser(emailIntent,"Share image using"));