I have an app that observes a public directory on external storage with FileObserver
.
It works fine on Lollipop
devices. I want to add support for Marshmallow
, so I set up a Nexus 9 tablet with it.
On the Marshmallow device, it fails, on Lollipop device it's OK.
On Marshmallow device, the FileObserver
does not react to file system events that are caused by other processes. E.g. taking a screenshot, creating files via adb
shell.
It works fine if the files are created by my app.
On Marshmallow
, I ask for WRITE_EXTERNAL_STORAGE
and READ_EXTERNAL_STORAGE
permissions from Manifest.xml
.
When I compile with API 23, I also make sure that I call ActivityCompat.requestPermissions()
.
When I compile with API 22, I just rely on Manifest.xml
.
It works if I observe stuff on /data/data/my-package-name
.
It fails if I observe stuff on /storage/emulated/0/Pictures/Screenshots
.
Did anybody test FileObserver
considreing all of the following? :
Marshmallow
deviceadb
or taking screenshot).This appears to be a bug in Marshmallow, see this link.
This is not fixed even in Nougat, you could get rid of the API this whole FileObserver, as it makes completely useless the fact that on most of the devices, it will not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With