I need to implement fileObserver in background, so if new file arrives in observed directory, a notification will have to be triggered. Considering the background limitation implemented from Oreo, easiest option is just to launch fileObserver in foreground service (with notification) and keep listening. However this will keep my app in battery drainers list and I would prefer avoiding adding notification all the time. Another solution is to implement scheduler in workmanager, but this will need me reading the whole directory very frequently ( in every minute or even less time) just to identify if any new file has arrived. This means I will avoid using fileObserver but will keep consuming precious resource unnecessarily every minute.
I am hoping if someone could suggest if there is any other more efficient way to implement the functionality of fileObserver guaranteeing the functionality but keeping the resource usage at the least.