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? :
Marshmallowdevice- API 23 and API 22?
- external storage
- files created by some other process than the observing app (e.g.
adbor taking screenshot).