gpt4 book ai didi

安卓\Intent : Send an email with image attachment

转载 作者:IT老高 更新时间:2023-10-28 23:17:48 25 4
gpt4 key购买 nike

收件人正在接收电子邮件,但没有附件。这是代码,哪位高手知道我哪里出错了?

 Intent messageIntent = new Intent(android.content.Intent.ACTION_SEND);

String aEmailList[] = { "mymailgmail.com" };
messageIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);

messageIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
...
messageIntent.setType("image/jpeg");
File downloadedPic = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "MyApp.jpg");

messageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));

startActivity(Intent.createChooser(messageIntent, getResources().getString(R.string.chooser_pic)));

我明白了:

file:// attachment path must point to file://sdcard. Ignoring attachment file://...file name is MyApp.jpg

我没有得到图像,只有上面的短信。谢谢。

最佳答案

试试下面的代码...

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From My App");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/Myimage.jpeg"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));

关于安卓\Intent : Send an email with image attachment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14457457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com