How to get notified of each new image being visible to the gallery app?

前端 未结 3 1703
渐次进展
渐次进展 2021-02-05 16:05

Background

When the user downloads a new image or captures one using the camera, the gallery app will get updated to show the new images.

I need to be notified

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 16:31

    i think you can acheive this using the FileObserver .

    as mentioned in the documentation :

    Monitors files to fire an event after files are accessed or changed by by any process on the device . Each FileObserver instance monitors a single file or directory. If a directory is monitored, events will be triggered for all files and subdirectories inside the monitored directory.

    but you have to keep in mind :

    If a FileObserver is garbage collected, it will stop sending events. To ensure you keep receiving events, you must keep a reference to the FileObserver instance from some other live object.

    Please give me some feedback . Hope That helps .

提交回复
热议问题