I'm trying to implement a ContentObserver on a Storage Access Framework provided Uri, but the observer is never notified of any change.
The example Uri I'm attempting to observe is:
content://com.android.externalstorage.documents/tree/primary%3AMusic/document/primary%3AMusic
The app has previously been granted the READ_URI_PERMISSION, via takePersistableUriPermission.
I've tried using the Uri returned from DocumentsContract.buildChildDocumentsUriUsingTree (which resolves to /tree/primary:Music/document/primary:Music/children).
I've also tried DocumentFile.fromTreeUri(context, uri) (which resolves to /tree/primary:Music/document/primary:Music).
I've tested adding and removing files directly to this Music directory via adb and using the Files app on the device, but the ContentObserver onChange() callbacks are never called.
I have noticed that when registering the same ContentObserver against MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, I do receive change notifications - so there doesn't appear to be a problem with the ContentObserver implementation. Unfortunately, some of the directories I'd like to observe are not tracked in the MediaStore.