我正在尝试使用 tcp 套接字发送文件列表,但我收到此文件提供程序错误。如果有人可以,请提供帮助。谢谢
原因:java.lang.IllegalArgumentException:无法找到包含 >/storage/708A-1A0F/- CHAIN YE DILLAN DA - MUHAMMAD UMAIR ZUBAIR QADRI - OFFICIAL HD VIDEO.mp4 at >androidx.core.content.FileProvider$ 的已配置根目录SimplePathStrategy.getUriForFile(FileProvider.java:800) 在 androidx.core.content.FileProvider.getUriForFile(FileProvider.java:442)
文件路径
Set<String> keys = BaseApplication.sendFileStates.keySet();
if (keys.size() > 0) {
for (String s : keys) {
File newFile = new File(s);
Uri contentUri = FileProvider.getUriForFile(this, "com.Jubilant.wifiproject", newFile);
uris.add(contentUri);
}
Log.d("contentUri", "onCreate: " + uris);
}
文件路径.xml
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="external_files"
path="." />
<cache-path
name="external_cache"
path="."/>
<external-cache-path
name="external_cache_path"
path="."/>
<external-files-path
name="external_files_path"
path="."/>
<external-media-path
name="external_media_path"
path="."/>
<files-path
name="files_path"
path="."/>
</paths>
清单.xml:
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.Jubilant.wifiproject"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_path" />
</provider>