Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 电子邮件/共享意图,设置附加文件的文件扩展名_Android_Android Intent - Fatal编程技术网

Android 电子邮件/共享意图,设置附加文件的文件扩展名

Android 电子邮件/共享意图,设置附加文件的文件扩展名,android,android-intent,Android,Android Intent,是否可以设置所附意图的文件扩展名 这段代码对我来说很有用,但是附加的图像有像flag_be这样的文件名,并且没有被接收电子邮件的客户机识别为图像,因为我猜缺少扩展名。只要更改名称,附件就有效且未损坏 Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is my text

是否可以设置所附意图的文件扩展名

这段代码对我来说很有用,但是附加的图像有像flag_be这样的文件名,并且没有被接收电子邮件的客户机识别为图像,因为我猜缺少扩展名。只要更改名称,附件就有效且未损坏

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is my text");
emailIntent.putExtra(Intent.EXTRA_SUBJECT,"This is the subject!");
emailIntent.setType("image/png");

ArrayList<Uri> uris = new ArrayList<Uri>();
uris.add(Uri.parse("android.resource://" + getPackageName() + "/drawable/flag_be"));

emailIntent.putExtra(Intent.EXTRA_STREAM, uris);

startActivity(emailIntent);
等等

Android上的Gmail客户端无法发送附件

我错过什么了吗


尊敬的Jan,这样的资源是无法共享的。您必须先将其复制到sdmedia,然后才能设置文件名。或者使用ContentProvider

uris.add(Uri.parse("android.resource://" + getPackageName() + "/drawable/flag_be.png"));
uris.add(Uri.parse("android.resource://" + getPackageName() + "/drawable-xhdpi/flag_ag.png"));