I've a widget with nine-patch image background. The image was saved in /sdcard/mydir/bgs.
When I try to load a image with setImageViewUri method, I've this error:
Unable to open content: file:///storage/emulated/0/sdcard/mydir/bgs
..
then
...
open failed: EACCES (Permission denied)
This appears only on the the home screen and only with Nexus 10 and Nexus 7 (with latest launcher 4.4 this bug not exist). I've also have some RemoteViews on my application and all works correctly.
I've also added into manifest either READ_EXTERNAL_STORAGE, either WRITE_EXTERNAL_STORAGE.
How can I solve?
UPDATE: I've inspect the method setImageViewUri and I've found that it changes the path of my file.
if (value != null) {
// Resolve any filesystem path before sending remotely
value = value.getCanonicalUri();
if (StrictMode.vmFileUriExposureEnabled()) {
value.checkFileUriExposed("RemoteViews.setUri()");
}
}
This method receive my value (/sdcard/mydir/bgs) and changes it into (storage/emulated/0/sdcard/mydir/bgs). But this file not exists into system via adb.
As from Lollipop, Google introduced a new way of explicitly giving apps the permission you want them to use on your device and disabling the ones you want to deny the app. If you notice, in your android monitor, the log shows
java.io.FileNotFoundException: /storage/emulated/0/advert.mp4: open failed: EACCES (Permission denied)
EACCESS permission denied
is the cause of the java's infamous FileNotFoundException
.
To solve this, just goto your App permission and enable storage for your app