I have an application that practically does not require user interaction, but requires Geofences. Can I run this completely in the background?
An action will be taken when the service is first started. This operation will start the service and register BroadcastReceiver for BOOT_COMPLETED, so the service will start at boot. This action is unlikely to be triggered again.
The service will periodically set an alarm that causes IntentService to download a list of locations from the network. This IntentService will then configure Geofences around these locations and create PendingIntents that will fire when locations are approached. In turn, these PendingIntents will force another IntentService to take some action.
All this should happen in the background, without user interaction, except for starting the Activity for the first time after installation. Consequently, Activity will not interact with LocationClient or any location services.
I have this setting with proximityAlerts, but you want to upgrade to the new Geofencing API for battery use. However, I heard that there may be several problems using LocationClient from the service. In particular, what I heard (sorry, no links, just rumors):
- The location client relies on ui availability for error handling.
- When called from a background thread, LocationClient.connect () assumes that it is called from the main ui thread (or another thread using an event looper), so the connection callback is never called if we call this method from a service running in the background thread
When I researched, I see no reason why this will be so, or why it will stop my execution of what I want. I was hoping this would be almost a replacement for proximityAlerts ...
Can anyone shed some light on things here?
source share