I am developing an app which开发者_开发百科 uses GPS in many Activities. At first I thought of implementing the LocationListener in each Activity. However I wonder if is possible a better approach to the problem by having a service with the GPS. What do you think is the right path to follow?
You can create a base activity class that implements the LocationListener interface, and have all your location-aware activities subclass this base activity. Since only only one activity is active and in the foreground at a time, there's no waste of resources here. (Assuming you register in onResume, and call removeUpdates in onPause for instance)
精彩评论