gpt4 book ai didi

java - 由于错误代码 : Failed to find configured root that contains,无法使用共享图像按钮

转载 作者:行者123 更新时间:2023-12-01 18:15:41 25 4
gpt4 key购买 nike

我正在创建一个共享图像按钮,但由于某种原因我收到这样的错误代码:

java.lang.IllegalArgumentException: Failed to find configured root that contains /document/image:74
at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:744)
at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:418)
at com.jawad.photoeditor.MainActivity$5.onClick(MainActivity.java:163)

我的 list 看起来像:

<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/fileprovider" />
</provider>

我的fileprovider.xml看起来像:

<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="external_files"
path="." />
<external-files-path
name="external_files"
path="." />
<cache-path
name="cache"
path="." />
<external-cache-path
name="external_cache"
path="." />
<files-path
name="files"
path="." />
</paths>

我的特定代码看起来像:

final Button shareButton = findViewById(R.id.shareButton);
shareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

File file = new File(imageUri.getPath());
Intent intent = new Intent(Intent.ACTION_SEND);
FileProvider.getUriForFile(Objects.requireNonNull(getApplicationContext()),
BuildConfig.APPLICATION_ID + ".provider", file);
intent.setDataAndType(imageUri, "image/*");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(intent);
}
});

尝试过,但没有解决问题。任何帮助将不胜感激,提前致谢!

最佳答案

所以我刚刚尝试在我的 xml 文件中添加根路径。

<root-path name="root" path="." /> 

现在它就像一个魅力。问题已解决

关于java - 由于错误代码 : Failed to find configured root that contains,无法使用共享图像按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60375053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com