I’ve to acquire data from various sensors like accelerometer, gyroscope, microphone and GPS.
The sensing action shouldn’t be continuous, but rather single short intervals of sampling should be periodically scheduled according to various policy (for example power saving). Each sensor sampling action lasts few seconds, say 5 seconds.
I would realize a “Client” for each sensor, deputed to the listening of sensor data when necessary, and a “Controller” that control the execution of Clients, but I’m not sure about the way to realize this.
Is it correct to realize a Service for each Client? or would be better a simple AsyncTask or Handler?
It’s better if each Client is responsible of a single sensing action, executed in a single onStartService(), or if the onStartService() action enable a periodic action of sampling?
Help would be appreciated.
This sounds like a task for a
Service, that is triggered byAlarms at (regular) scheduled intervals.An
AsyncTaskis usually something that is started after the user has done some interaction and the system is supposed to do a “long running” operation (like network i/o), which could otherwise block the UI.Note that it is very well possible to also trigger a service like an
AsyncTask– have a look atIntentService.