Bug 60979 - Android.OS.FileObserver does not fire FileObserverEvents.Create and stops working after the first few events
Summary: Android.OS.FileObserver does not fire FileObserverEvents.Create and stops wor...
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 8.1 (15.5)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2017-12-04 22:22 UTC by Csányi István
Modified: 2017-12-13 09:35 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Source of the service that's starting the observer. (1.53 KB, text/plain)
2017-12-04 22:22 UTC, Csányi István
Full Android Studio project (2.68 MB, application/x-rar)
2017-12-13 09:34 UTC, Csányi István
Full Xamarin Android project (8.06 KB, application/x-rar)
2017-12-13 09:35 UTC, Csányi István

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 60979 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Csányi István 2017-12-04 22:22:38 UTC
Created attachment 25905 [details]
Source of the service that's starting the observer.

Android.OS.FileObserver does not fire Create event and some others 
also stops working after the first few events

Only getting these events after taking a photo when the fileobserver set to watch the DCIM/Camera folder:
> Open : 32 : IMG_20171204_230325.jpg
> Access : 1 : IMG_20171204_230325.jpg
> CloseNowrite : 16 : IMG_20171204_230325.jpg

public override void OnEvent(FileObserverEvents e, string path) {
    Android.Util.Log.Debug(TAG, e.ToString() + " : " + (int)e + " : " + path);

The next photo taken fires no event.

The app has ReadExternalStorage and WriteExternalStorate permissions.
The app keeping a reference to the observer

Ported the same code and tested in java + android studio and it works correctly.
Comment 1 Jon Douglas [MSFT] 2017-12-13 00:03:25 UTC
Can you please attach the Xamarin.Android project and the equivalent Android Studio project for us to investigate further based on your observations?

Thank you for the report!
Comment 2 Csányi István 2017-12-13 09:34:54 UTC
Created attachment 25988 [details]
Full Android Studio project
Comment 3 Csányi István 2017-12-13 09:35:52 UTC
Created attachment 25989 [details]
Full Xamarin Android project