Class LocationHelper


  • public class LocationHelper
    extends Object
    Since:
    05-Dec-2011 8:59:01 AM
    • Constructor Detail

      • LocationHelper

        public LocationHelper​(android.content.Context context)
        Constructor. Takes into account what GPS settings are in place.
        Parameters:
        context - Context of the activity its called from.
      • LocationHelper

        public LocationHelper​(android.content.Context context,
                              int updateRate,
                              LocationDelegate windowDelegate)
        Constructor. Takes into account what GPS settings are in place.
        Parameters:
        context - Context of the activity its called from.
        updateRate - Update rate in seconds when the listener will next try to get a new location. Note: this is the min time possible for a next update to occur.
        windowDelegate - Window listeners delegate to pass a notification that the location has been updated.
    • Method Detail

      • getLastLocs

        public LinkedList<android.location.Location> getLastLocs()
      • setLastLocs

        public void setLastLocs​(LinkedList<android.location.Location> lastLocs)
      • setCurrentLocation

        public void setCurrentLocation​(android.location.Location currentLocation)
      • enableDebug

        public void enableDebug()
      • disableDebug

        public void disableDebug()
      • addLocationToQueue

        public void addLocationToQueue​(android.location.Location l)
        Adds location to queue.
        Parameters:
        l - Location
      • requestLocationUpdates

        public void requestLocationUpdates()
        Requests the current location based on passive,network, and GPS provider.
      • requestLocationUpdates

        public void requestLocationUpdates​(String provider)
        Requests the current location based on a specific provider.
        Parameters:
        provider - provider to use.
      • getSingleLocation

        public boolean getSingleLocation​(SingleLocationObserver observer)
        Starts listening for a single location. Returns true if a provider is enabled.
        Parameters:
        observer - SingleLocationObserver obj
        Returns:
        boolean
      • compareToLoc

        public boolean compareToLoc​(float lat,
                                    float longitude,
                                    float radius)
        Parameters:
        lat - double
        longitude - double
        radius - float
        Returns:
        boolean
      • getCurrentLocation

        public android.location.Location getCurrentLocation()
        Gets the current Location
        Returns:
        Location object
      • isBetterLocation

        protected boolean isBetterLocation​(android.location.Location location)
        Determines whether one Location reading is better than the current Location fix
        Parameters:
        location - Location obj
        Returns:
        boolean
      • removeUpdates

        public void removeUpdates()
        Stops requesting location updates from the location manager. Keep in mind fragment and activity life cycles and remember to remove updates.
      • getUpdateRate

        public int getUpdateRate()
        Gets the update rate in seconds
        Returns:
        int
      • setUpdateRate

        public void setUpdateRate​(int updateRate)
      • locationToLatLng

        public static com.google.android.gms.maps.model.LatLng locationToLatLng​(android.location.Location loc)
      • getContext

        public android.content.Context getContext()
      • isGpsProviderEnabled

        public boolean isGpsProviderEnabled()
      • isNetworkProviderEnabled

        public boolean isNetworkProviderEnabled()