1
I need to develop an application for android where the same work monitoring a certain directory with a certain periodicity and sending new files from this directory to an FTP or any other folder of the local network that the device is connected. Ex.: Every two minutes monitor the camera directory and whenever a user takes a new photo, this monitor check if there are new photos and send to a local network directory. How to work with this type of app on android?
ramaral, thank you very much... I have a question: I need the application to run in the background all the time, in fact it doesn’t even have interface, it just needs to do this monitoring... what is the most correct way to do this?
– Fábio Azevedo
Create a service to monitor and define a Broadcastreceiver that is called after the boot of the device. The Broadcastreceiver will be used to start the service.
– ramaral
Right... for a better understanding, in this case the service will always run respecting the Filemonitor class or would it be necessary to define a periodicity for execution of it? How would the interaction between the two (Broadcastreceiver and Filemonitor class )?
– Fábio Azevedo
In the service you create an instance of the Filemonitor class and call
monitor.startWatching();
. Broadcastreceiver will be used to start the service. Broadcastreceiver as I explain here it will launch after starting the device and the service will always be running.– ramaral