Question

I am making an android app. I have a main activity and i want to show distance and speed on main activity. But there is a button View Map on main activity as well. If user clicks it then he/she should see his/her travelled track on map. User should stop his/run from main activity means that user should be able to go back to main activity and then stop. How can i create map activity which runs in background and show distance and speed in main activity. Thanks in advance.

Was it helpful?

Solution

You should probably not think about having an Activity run in the background and instead have some other object that manages all the location information. Most of the time, you only have one Activity on screen and when its not on screen, it is paused and not working.

I would try to have an class that extends LocationListener, manage location information in that object, then whenever it is needed, plug the information into an appropriate View that is shown when the user presses "View Map" button you have.

OTHER TIPS

You should take a look at the Google MyTracks app, it does exactly what you want and it is open source.

http://code.google.com/p/mytracks/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top