Questions tagged [fileobserver]

A simple abstract class developers can use to detect changes to a directory (nonrecursively) and fire callbacks as a result.

Monitors files (using inotify) to fire an event after files are accessed or changed by any process on the device (including this one). FileObserver is an abstract class; subclasses must implement the event handler onEvent(int, String).

Full Documentation Link: http://developer.android.com/reference/android/os/FileObserver.html

130 questions
4
votes
2 answers

FileObserver instance is being garbage collected

I need to monitor all files in a folder, when a file opened (FileObserver.OPEN) I want to execute a method. The problem is some times, the FileObserver instance is collected by GC, I tried this: final MyFileObserver fo = new…
danilodeveloper
  • 3,840
  • 2
  • 36
  • 56
4
votes
3 answers

Linux + Java + Windows : Check if file copied completely

I have a Java application which monitors a directory for new files and process any new file it sees in the directory. Application needs to run on both linux and windows env. The issue is on linux, when a user manually copies a file in the directory,…
Prashant
  • 152
  • 1
  • 16
4
votes
2 answers

FileObserver not registering CREATE in onEvent

I have a pretty simple implementation of FileObserver: observer = new FileObserver(rootPath+"Pictures") { @Override public void onEvent(int event, String path) { //event &= FileObserver.ALL_EVENTS; …
Blair Holmes
  • 1,521
  • 2
  • 22
  • 35
4
votes
0 answers

Screenshot Detection & Retrieval On Android

I am looking for a universal solution to detect a screenshot when it is taken and retrieve the path/filename to the image. I started with the FileObserver object and it seemed like it might work, however, I could not find a reliable way to get the…
4
votes
0 answers

Why the FileObserver cannot work on some other Android versions or phones?

I have tried it on three phones, but my FileObserver can only work on a phone that works on Android 4.2.2, and it cannot catch any event on other versions.Here is my code: in AndroidMenifest I already added uses-permissions:
KevinYe
  • 61
  • 4
4
votes
2 answers

FileObserver not Working android 4.4.3

Updated nexus 5 to 4.4.3. Fileobserver not working for any directory . I tried 1./data/data/com/whatsapp , 2.sdcard/Movies and also 3. "/". Before the update it was working fine. I saw the RecursiveFileObserver on github and used it along with my…
3
votes
0 answers

FIleObserver android 10 issue

I have developed an app that works up to Android 9 and with Android 10 it doesn't. The app should wait for a new file to be created in a specific folder and then perform some actions, my main suspect is FileObserver because with the API 29 it tells…
Francesco
  • 43
  • 7
3
votes
0 answers

FileObserver doesn't work at all

I'm trying to detect file changes in DCIM/Camera directory. But event doesn't trigger, when I make a picture with camera. I've tried to create a Service to be sure observer didn't close, but it didn't help. It doesn't trigger even if I copy files…
tikhpavel
  • 399
  • 3
  • 10
3
votes
1 answer

How to know if removed File monitored by File Observer is a Directory or a File

I'm using FileObserver to monitor changes in folders. Events are triggered as expected but I have problem making a distinction between Files and Directories in the events DELETE and MOVED_FROM, since after the event is triggered, calling both…
Gotiasits
  • 1,135
  • 1
  • 10
  • 21
3
votes
1 answer

FileObserver listening on background, Android O

I have FileObserver in my application, now it runs on the background and if new file registered - instantiate uploading of it to some server in foreground service. In Android O we should use FirebaseJob Dispatcher to do some job in background, but…
3
votes
4 answers

FileObserver doesn't work

In my Android app I want to detect events from directory. Here is code: String path = Environment.getExternalStorageDirectory() + File.separator + "test2"; Log.d("test", "path is " + path); FileObserver fileObserver = new…
TOP
  • 2,574
  • 5
  • 35
  • 60
3
votes
4 answers

File observer stops working after some time

I want to listen to the changes occured in file system.I am using FileObserver.Here is my code: Code: class MyDirObserver extends FileObserver { String superPath; public MyDirObserver(String path) { super(path, ALL_EVENTS); …
Nemat
  • 101
  • 2
  • 4
3
votes
2 answers

Better than FileObserver

I'm curious to know if there's a better way to monitor a directory for file changes/creations/deletions than FileObserver. FileObserver requires a constant reference to it, which requires a constantly running service, which is difficult and a bad…
Osmium USA
  • 1,751
  • 19
  • 37
3
votes
0 answers

Mac FSEvents - How to detect if a file or directory was deleted/removed

I use the FSEvent API to detect file modifications. I'm already able to detect when new files/folders are created or renamed. But I can't detect if a file was removed/deleted. When I delete a file I get a kFSEventStreamEventFlagItemRenamed and not…
Tobi Weißhaar
  • 1,617
  • 6
  • 26
  • 35
3
votes
2 answers

android, MediaScanner vs FileObserver for monitoring media file created

What is the best option (MediaScanner/FileObserver) to monitor couple of paths (both internal and external memory of device) for media files being created. I need to get a event when ever a media file is being created in folder that is being…
1
2
3
8 9