I need to listen to new images that comes from any source like downloading images, capture new images, other apps download images..etc Is there any listener that will trigger event whenever new photos is added to gallery? I have been searching for two days. I could not get anything solid.
I read about FileObserver
, will that help?
means it has been added to the
MediaStore
.First of all,
FileOberver
is a memory-killer approach. Consider a high volume of files. RatherContentObserver
seems a far better approach.Probably a good idea to do this in a service (ever running)! You will also need to unregister in the
onDestroy()
Warning: This only tells you when the MediaStore has been changed, it does not tellly anything specific about addition/deletion. For this, you may have to query the MediaStore to detect any change from your previous database or something.