Reputation: 681
I'm looking to build something similar to Google's field trip application. The key attributes that I'm looking to prove out are:
My reading has brought me to a number of different classes/APIs from broadcast reciever of on boot, to regular services, to alarm manager, etc. It seems there are multiple ways this could be made to work, I'm curious what the community recommends as a high level approach?
Upvotes: 2
Views: 455
Reputation: 332
I think you may divide your solution into two parts :
Starting the app or the service after the device re-boot process completed by defining a Broadcast receiver that has the following action :
And on the "onReceive" method of the broadcast "do your task " start the service that listen to the location service updates.
For the part of listening to the location updated every x minutes, you would better use the alarm manager to "wake up" the service every x minutes, and every service sets the alarm for the next call.
Upvotes: 1
Reputation: 173
You would definitely want to use a broadcast manager to get the boot event.
As far as polling for location goes, it sounds like you would want to use a Service and start it once you received the boot event. Services
You could then use an event bus like Otto to communicate your events to wherever you need.
As far as the timing goes you could use a job manager to run things at various intervals, or just simply create a runnable and have it run as often as you like. As long as you keep it in the service, you should be able to control the length that it will run just fine. Regardless of whether or not the app is closed.
Upvotes: 1