无法使用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 (将#修改为@)