我有一个九个补丁图像背景的小部件.图像保存在/ sdcard/mydir/bgs中.
当我尝试使用setImageViewUri方法加载图像时,我遇到了以下错误:
Unable to open content: file:///storage/emulated/0/sdcard/mydir/bgs
Run Code Online (Sandbox Code Playgroud)
..
然后
...
open failed: EACCES (Permission denied)
Run Code Online (Sandbox Code Playgroud)
这只出现在主屏幕上,只有Nexus 10和Nexus 7(最新的启动器4.4不存在此错误).我的应用程序上也有一些RemoteView,一切正常.
我还在清单中添加了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()");
}
}
Run Code Online (Sandbox Code Playgroud)
此方法接收我的值(/ sdcard/mydir/bgs)并将其更改为(storage/emulated/0/sdcard/mydir/bgs).但是这个文件不是通过adb存在于系统中的.