0

I am writing an application that uses GPS to give distance to a starting line and speed and direction to that line. I have GPS running fine in a test file I wrote that prints out latitude and longitude and time to my cell phone display but it is a single activity. I need to have my program do calculations in the background on the GPS data, for example calculating speed from differences in location 10 seconds apart. This information needs to be viewed from several of my activity pages, which are individual classes. I think I need to create a helper class that contains the GPS service but I am not sure and not sure of the many things that are on the web what I should be looking at. Not sure how or where to fire off the helper and even if it is called helper as I can't find that in the Android docs. Also not sure what the best way to get the information from the GPS helper, if that is what it is called. After several hours of googling and searching Youtube, I am coming here for help.

4

1 回答 1

0

What I would suggest doing is using a Service to store the data you need and perform the calculations. You can then create custom methods in the service and access them directly or via AIDL. The Activities that view the data can then access the data either using something like a refresh button to call the methods that access the data or by using a timer to poll those methods at regular intervals.

于 2012-07-10T02:51:31.810 回答