java - 当我尝试共享文件时,它的节目格式不支持味精
问题描述
Intent intentShareFile = new Intent(Intent.ACTION_SEND);
intentShareFile.addFlags( Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intentShareFile.setType("application/*");
intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.parse("content:/"+path));
Intent shareIntent = Intent.createChooser(intentShareFile, "share");
startActivity(shareIntent);
我正在使用此代码使用意图组件发送文件...但它显示错误消息...
解决方案
不要使用:Uri.parse("content:/"+path)
尝试使用:FileProvider.getUriForFile(getContext(), getContext().getPackageName() + ".FileProvider", path)
推荐阅读
- node.js - 使用会话文件存储随时间增加 CPU 峰值
- variables - Azure DevOps 变量输出到另一个作业导致空值
- symfony - Symfony5 服务:自动装配参数不起作用
- c# - 使用 HtmlAgilityPack 从 C# 中的网站抓取特定数据
- oracle - Linux 服务器应用程序使用 NLS_CHARACTERSET WE8ISO8859P1 咨询 Oracle(重音问题)
- azure-active-directory - 2021 年 3 月更改为 Azure AD B2B 兑换流程实际上意味着什么?
- python - 熊猫数据框太大而无法附加到 dask 数据框?
- vue.js - Vue - 在不更改父属性值的情况下更改计算属性值
- java - 无法在斯坦福 CoreNLP Java API 中加载标记模型
- node.js - socket.io 没有在 macos safari 上连接