使用Uri时拒绝权限

问题描述

我正在尝试使用存储在字符串中的Uri加载图像并插入SpannableString中,但是我收到以下错误消息:

java.lang.SecurityException: Permission Denial: opening provider com.android.providers.downloads.DownloadStorageProvider from ProcessRecord{c16d076 5450:com.example.veloz/u0a87} (pid=5450,uid=10087) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs

我的代码:

for (int i = 0; i < thisPage.images.size(); i++) {

                    SpannableString string = new SpannableString(inputText.getText());

                    Uri imageData = Uri.parse(thisPage.images.get(i).uriText);

                    string.setSpan(new ImageSpan(getApplicationContext(),imageData),thisPage.images.get(i).position - 1,thisPage.images.get(i).position,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                    inputText.setText(string);
                }

我如何获得这样做的许可?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)