Hi, I want to make an Android application that continues to run in background and when user accesses any folder, picture, or any other file it notifies using toasts that he accesses this file(filename).
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can do that by using Services in Android. Here is a nice tutorial for doing that.
Services
Also you can download a sample from my respository.
回答2:
The other people answering your question are focused on the "background" part, and a Service
would indeed accomplish this. Users have fairly loudly stated that they despise constantly-running services like the one you are proposing.
when user access any folder or picture or any file it notify using tosts that he acess this file(filename).
For files that you can access yourself (e.g., those on external storage), you can use FileObserver
class.
回答3:
Use FileObserver
to detect file access or change.