我正在尝试在 Android 4.2 锁屏上的应用程序中启用我的小部件,它工作正常,但是它无法解析任何图像 uri。我得到的错误是这样的:
java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.tvshowfavs/cache/22kifo7sdmyet7x7kphdgch69: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:416)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at java.io.FileInputStream.<init>(FileInputStream.java:105)
at android.content.ContentResolver.openInputStream(ContentResolver.java:447)
at android.widget.ImageView.resolveUri(ImageView.java:636)
at android.widget.ImageView.setImageURI(ImageView.java:381)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.widget.RemoteViews$ReflectionAction.apply(RemoteViews.java:1146)
at android.widget.RemoteViews.performApply(RemoteViews.java:2304)
at android.widget.RemoteViews.apply(RemoteViews.java:2263)
at android.widget.RemoteViewsAdapter$RemoteViewsFrameLayout.onRemoteViewsLoaded(RemoteViewsAdapter.java:286)
at android.widget.RemoteViewsAdapter$RemoteViewsFrameLayoutRefSet.notifyOnRemoteViewsLoaded(RemoteViewsAdapter.java:335)
at android.widget.RemoteViewsAdapter$4.run(RemoteViewsAdapter.java:993)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)
Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:400)
任何人都知道为什么它无法打开存储在模拟存储中的图像?此图像之前已使用 Environment.getExternalStorageDirectory() 下载并缓存,因此应正确写入存储目录。这是在尝试加载任何图像时收到此异常的 Nexus 10 上。任何帮助表示赞赏。