- 更新到最新包
- 新建 wxapi/WeChatShareProvider
package com.dm_guide.wxapi;
import androidx.core.content.FileProvider;
public class WeChatShareProvider extends FileProvider {
}
- res/xml中添加jshare_file_provider_paths.xml文件
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<!--自定义配置分享文件目录访问权限-->
<external-path name="sample-external-path" path="/"/>
<files-path name="sample-files-path" path="/"/>
</paths>
- AndroidManifest.xml中添加
<!--支持Android11以上系统,需要配置分享文件目录访问权限-->
<provider
android:name=".wxapi.WeChatShareProvider"
android:authorities="${applicationId}.JSharefileprovider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/jshare_file_provider_paths" />
</provider>