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

122 questions
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

Multiple FileObserver on same file failed

In my application, I have different components, which monitor the particular file in sdcard using FileObservers. So there are two instances of File Observer which observe a single file, say abc.xml for all events. FileObserver fo1 = new…
darthvading
  • 809
  • 2
  • 10
  • 23
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
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,671
  • 2
  • 33
  • 54
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,080
  • 1
  • 10
  • 20
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,657
  • 19
  • 33
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,567
  • 5
  • 24
  • 34
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…
3
votes
2 answers

Android FileObserver onEvent not getting called

Can someone possibly help me with this? I want to observe a file to see if it gets modified so that I can update the activity. After several tests, I've determined it's just plain not working. Am I doing something wrong? I'm creating a FileObserver…
Richard Rhyan
  • 193
  • 4
  • 17
2
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
  • 33
  • 5
2
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
  • 192
  • 2
  • 10
2
votes
0 answers

Run FileObserver inside JobIntentService

My app runs a FileObserver inside a service (the service runs 10 minutes after a temp file is created, and it observes the file for 60 seconds in order to delete it if it's not used). Due to Android 8 restrictions, I cannot start a service from…
2
votes
0 answers

how to run FileObserver in background(onPause)in android?

I am developing android application with Fragment,now i want to run FileObserver in background when fragment is paused. My Code: FileObserver observer = new FileObserver(android.os.Environment.getExternalStorageDirectory().toString() + "/MyApp/")…
1
2
3
8 9