我有一个带有九宫格图片背景的小部件。
这个图片保存在 /sdcard/mydir/bgs 中。
当我试图使用 setImageViewUri 方法加载图片时,出现以下错误:
Unable to open content: file:///storage/emulated/0/sdcard/mydir/bgs
然后
...
open failed: EACCES (Permission denied)
这仅在主屏幕上出现,并且仅适用于Nexus 10和Nexus 7(使用最新的4.4启动器时,此错误不存在)。 我的应用程序中还有一些RemoteViews,并且所有内容都可以正常工作。
我也已经将READ_EXTERNAL_STORAGE和WRITE_EXTERNAL_STORAGE添加到清单中。
我该如何解决?
更新:我已检查了setImageViewUri方法,并发现它更改了我的文件路径。
if (value != null) {
// Resolve any filesystem path before sending remotely
value = value.getCanonicalUri();
if (StrictMode.vmFileUriExposureEnabled()) {
value.checkFileUriExposed("RemoteViews.setUri()");
}
}
这个方法接收了我的值(/sdcard/mydir/bgs),并将它改变为(storage/emulated/0/sdcard/mydir/bgs)。但是,通过adb在系统中找不到该文件。