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
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
  • 203
  • 1
  • 6
  • 17
2
votes
0 answers

Observers don't get notified when LiveData is set through FileObserver

I have a sharedViewModel with LiveData properties. MainActivity: private val logViewModel by viewModels() fun startLocationUpdates() { val locationItem = LocationItem(...) logViewModel.addLogEntry(locationItem) …
Houman
  • 64,245
  • 87
  • 278
  • 460
2
votes
1 answer

FIleObserver NoSuchMethodError in Android 10

I have a FileObserver(File dir) that works perfectly in Android11, but crashes badly in Android10 with the following LogCat even when I try to access the own APP private folder (external sdcard): E/AndroidRuntime(24651): java.lang.NoSuchMethodError:…
Luis A. Florit
  • 2,169
  • 1
  • 33
  • 58
2
votes
1 answer

Alternative to the deprecated FileObserver constructor for API level <29

According to the documentation, both FileObserver(path: String!) and FileObserver(path: String!, mask: Int) are deprecated (I don't know when). However, all other constructors were only added in API 29 (10/Q) and I'm trying to support from API 19…
vesperto
  • 804
  • 1
  • 6
  • 26
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/")…
2
votes
2 answers

How to create a Continues running background file upload in android?

I am developing an android application that can upload images one by one of a specific folder to the server from background without interrupting the UI. What I implemented is a intentService calls from the launcher activity with the runtime…
2
votes
1 answer

Monitor a folder in an Android Service

I have an Android app and I want to monitor a folder. I made a service(I want to monitor the folder non-stop, even if the user kill the app) and I put the folder's path in the extras of the Intent. In the service I have a FileObserver that should…
Alex Hash
  • 21
  • 1
2
votes
1 answer

Android | contentObserver | Content URI does not contain the resource ID

I am trying to detect screenshot on an Android app. I am using contentObserver to detect the change in the media directory, not using FileObserver because of known issue with it on Android M. Here is the code snippet: handlerThread = new…
2
votes
0 answers

FileObserver onCreate Event does not trigger itself in activity

I defined FileObserver class outside the activity public class MyFileObserver extends FileObserver { public String absolutePath; public MyFileObserver(String path) { super(path, FileObserver.ALL_EVENTS); absolutePath =…
Altaf Hussain
  • 25
  • 1
  • 1
  • 6
2
votes
0 answers

Android FileObserver - create new file

I have to create a file mechanism which creates a new file, check at real time if the file has reached to some length and then open a new file in order to write the extra data. But then, if the new file has also reached the same limit, open a new…
Elior
  • 3,178
  • 6
  • 37
  • 67
2
votes
0 answers

How to detect media file changes(Create/delete) instantly in android for mediaplayer

How to make an android app to listen to media file changes(Create/Delete) like Google Play Music app. How Play music app detect file changes while running and how it update the media list instantly. I have tried FileObserver but never worked. Is…
Aravinth thiyagarajan
  • 2,193
  • 3
  • 12
  • 10
2
votes
4 answers

android fileObserver onEvent not being called

I am trying to determine when a file is modified. Currently I have a class file observer class that contains public class fileObserver extends FileObserver { public String absolutePath; public fileObserver(String path) { super(path,…
Alexander Wen
  • 33
  • 1
  • 7
2
votes
1 answer

How to detect File downloaded in android

Is their a way to detect file is downloaded, any broadcast receiver, file observer, content observer or any other method & get its path. I have google it but didn't find any luck. Looking forward for your experience advice. Note : I can detect new…
Creator
  • 95
  • 1
  • 1
  • 7
2
votes
1 answer

Retrieve new and old path of a renamed file under observing directory

My App saves recorded video files in a specific folder in external directory and saves meta data including the path of every file in database . I need to Observe remove , rename and move of my file in case of keeping database updated with new file…
Armin
  • 599
  • 2
  • 8
  • 19
1 2
3
8 9