I read most of the questions and answers around SO and I must say I still have no idea on which way to go, in my case. There are several ways to go with but I can't really decide which one is best suited for my case.
What I've got
I have an Service that gets started from my app. It checks the current location of the user and calls a web service with the read location. This occurs every x meters.
What I want to obtain
- Have an activity with a map and display the current location readings from the service. This means my Activity needs to be informed on each location read. Keep in mind that this will be use only when the user starts the activity so I don't think that broadcasting each location from the service would be a good idea.
- An activity where I can ask the service for its last read location.
- As I mentioned before, the service reads location and needs to send it to a web server every few seconds. What would be the best approach for this ? In Service make a new Thread() for each web service call ? Use AsyncTask ? Sometimes I may receive as a response some extra values, case in which I need to start an Activity from the webservice.
Having this said, what would you recommend me to use ? Would this be a good approach: Example: Communication between Activity and Service using Messaging ?
LE: I have switched from IntentService to simple Service + thread for sending data to the web service. My IntentService implementation started and quickly for destroyed. Probably I did something wrong....