android - Android 10+ pdf doesnt send to Gmail
问题描述
I have files on my phone. I cant send pdf files to Gmail, for a test a created a list with png and pdf files, this files is located in the same folder. But, png files is sended to Gmail, pdf files didnt attachet. Cant understand why its happens
My code:
Intent emailIntent = new Intent(ACTION_SEND_MULTIPLE);
String theme = "Test";
emailIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
emailIntent.setType(" message/rfc822");
String to[] = {sendTo};
emailIntent.putExtra(EXTRA_EMAIL, to);
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
emailIntent.putExtra(EXTRA_SUBJECT, theme);
emailIntent.putExtra(EXTRA_TEXT, context.getResources().getString(R.string.text_email_message_body));
try {
((Activity) context).startActivity(Intent.createChooser(emailIntent, "Choose an Email client:"));
}catch (Exception e){
}
UPD:
this code is works on android 9 and 8
UPD:
i have added files like this:
ArrayList<Uri> uris = new ArrayList<>();
File fileIn1 = new File("/storage/emulated/0/TestApp/TestFolder/201123192703_1.png");
Uri u1 = Uri.fromFile(fileIn1);
File fileIn = new File("/storage/emulated/0/TestApp/TestFolder/201124171209_1.pdf");
Uri u = Uri.fromFile(fileIn);
File fileIn2 = new File("/storage/emulated/0/TestApp/TestFolder/201124171209_2.pdf");
Uri u2 = Uri.fromFile(fileIn2);
File fileIn3 = new File("/storage/emulated/0/TestApp/TestFolder/test.pdf");
Uri u3 = Uri.fromFile(fileIn3);
uris.add(u);
uris.add(u2);
uris.add(u1);
uris.add(u3);
解决方案
Replace emailIntent.setType(" message/rfc822");
with
emailIntent.setType("application/pdf")
推荐阅读
- python - 当对象在python的列表中时获取对象属性的最有效方法?
- sql - 如何计算不同专栏的年数和月数?
- jquery-select2 - 实现了选择ajax。如何防止它重新加载焦点?
- google-cloud-platform - 如何部署没有公共 IP 的计算实例
- kubernetes - 阿里云托管 Kubernetes Terraform
- python - 我正在尝试将视频按帧切割成多个部分,但代码不起作用
- mysql - mysql 5.6 及以后更改临时表列的数据类型
- php - 从服务器PHP中删除文件的有效方法
- facebook - Facebook 共享器或对话框 - 共享图像
- android-listview - Xamarin 适配器 FindViewById 返回 null