如何解决无法使用FileProvider与其他应用共享图像文件
我有图像列表,我想共享所选的图像。为此,我使用了 FileProvider 。我正在 Android 10 上运行应用程序。我也尝试了没有shareIntent(Intent.EXTRA_STREAM,uri),然后仅通过对话框打开应用程序共享。不共享任何内容后,仅返回应用程序。
在AndroidManifest.xml中;
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<Meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider_paths" />
</provider>
在路径中;
<paths>
<files-path
name="files"
path="/" />
<cache-path
name="cache"
path="/" />
这是我使用和开始意图的方式,
int pos = getAdapterPosition();
File imageFile = new File(imageQuotes.get(pos).getPath());
Uri uri = FileProvider.getUriForFile(mContext,BuildConfig.APPLICATION_ID + ".provider",imageFile);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setDataAndType(uri,"image/*");
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.putExtra(Intent.EXTRA_STREAM,uri);
mContext.startActivity(shareIntent);
运行该应用程序后,我为它选择了WhatsApp。我的图像文件作为BIN文件发送,并且在whatsapp上没有图像预览。 uri不是null,而是 content://com.scoto.partestestapplication.provider/files/SavedImageQuotes/Partes_1601815401590
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。