I'm developing an app that notices when a file inside a directory is opened by another application. I therefore use a FileObserver
that observes the directory.
When I'm running my application on a Nexus 5 (Android 6.0.1)
or Huawei P10 (Android 8.0.0)
, I'm able to receive a FileObserver.OPEN (32)
event when the other application opens a file inside the observed directory. I'm getting events in the following order:
Event Type: 1 (Access)
Event Type: 1 (Access)
Event Type: 16 (CLOSE_NOWRITE)
Event Type: 32 (OPEN)
Testing the application with the same application setup on a Galaxy S9+ (Android 8.0.0)
and a Google Pixel (Android 8.1.0)
the event is not triggered when a file is opened.
Event Type: 1 (Access)
Event Type: 1 (Access)
Event Type: 16 (CLOSE_NOWRITE)
The FileObserver.OPEN
event is missing. I can guess that the problem does not originate in the Android version as the S9+ shares one with the P10, but maybe I'm wrong.
Does anybody know what could be the problem, as I am pretty stuck here?