操作将邮件发送到带有文件 Android 11 [英] Action send mail to with file Android 11

查看:33
本文介绍了操作将邮件发送到带有文件 Android 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法共享.zip"文件使用 Gmail 应用或其他电子邮件发件人使用 Android 11 发送文件.

i have a problem to share a ".zip" file with gmail app or otherwise email sender with Android 11.

Intent email_intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",mailTo, null));
email_intent.putExtra(Intent.EXTRA_SUBJECT, "Log App");
email_intent.putExtra(Intent.EXTRA_TEXT,"");
email_intent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(getApplicationContext(), BuildConfig.APPLICATION_ID+".provider",new File(log)));
startActivity(Intent.createChooser(email_intent, getString(R.string.invia_tramite)));

我没有使用 requestLegacy 等,而是使用 getExternalFilesDir.对于 11 的较低版本,它可以工作.

I'm not using requestLegacy etc.. but getExternalFilesDir. With lower version of 11 it works.

请拯救我的一天:)

谢谢

推荐答案

通过替换解决:

Intent email_intent = new Intent(Intent.ACTION_SEND);
email_intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

并在清单中放置:

<queries>
    <intent>
        <action android:name="android.intent.action.SEND"/>
        <data android:mimeType="*/*" />
    </intent>
</queries>

这篇关于操作将邮件发送到带有文件 Android 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆