Android: Send location data in background periodically (every 30 seconds) and ask server for new data
Scenario: Post to server to get any new data in background every 30 seconds for long period i.e. 12 hours. Location data needs to be sent along with this. Current Implementation; Service Class; Location listener with interval of 30 seconds which sets the longitude & latitude values to two local variables Alarm manager fires pending Intent every 30 seconds to a broadcast receiver. Broadcast receiver starts an IntentService with location variables in the extras. The IntentService http posts location and asks for any new data from server. IntentService send server response back to main service