bhanu kaushik bhanu kaushik - 1 year ago 82
Android Question

Android : Get recently added media in Android Device similarly to File Manager

I am working on an application in which I have to notify user as soon as a new image, video, audio or apk is inserted by the user by any means (whether he downloads it or transfer it),similar to what File Manager application do.I don't know where to start from. Thanks

Answer Source

That is not possible in general. Your app has no rights to spy on the behavior of other apps. If the user, through my app, downloads something to my app's portion of internal storage, you cannot access that content (unless I choose to make it available) and you cannot find out that the content was added.

Beyond that, prior to API Level 24 (Android 7.0), there is no means for you accomplish this other than by trying to have a process running all the time. This is not good for the user, in terms of system RAM consumption and the like. Some users get very irritated when apps try to have a process run all of the time, and they may express their irritation in creative ways in the form of app store ratings.

All that being said, for publicly-accessible content (principally external storage), the simplest solution would be to set up a ContentObserver to monitor the MediaStore ContentProvider. On Android 7.0+, you could use JobScheduler to do the same thing, with the benefit that you do not need to keep your process running to keep the ContentObserver observing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download