首页 > 解决方案 > 当我尝试共享文件时,它的节目格式不支持味精

问题描述

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);

我正在使用此代码使用意图组件发送文件...但它显示错误消息...

标签: javaandroid

解决方案


不要使用:Uri.parse("content:/"+path)

尝试使用:FileProvider.getUriForFile(getContext(), getContext().getPackageName() + ".FileProvider", path)


推荐阅读