GpsEventSource

public class GpsEventSource

Fields

GPS_PROVIDER

public static final int GPS_PROVIDER

NETWORK_PROVIDER

public static final int NETWORK_PROVIDER

TWO_MINUTES

protected static final int TWO_MINUTES

mContext

protected Context mContext

mCurrentBestLocation

protected Location mCurrentBestLocation

mGpsLocationListener

protected GpsLocationListener mGpsLocationListener

mGpsStatusListener

protected GpsStatusListener mGpsStatusListener

mHasGPSFix

protected boolean mHasGPSFix

mLastLocation

protected Location mLastLocation

mListenProviders

protected int mListenProviders

mListeners

protected Queue<GpsEventListener> mListeners

mLocationManager

protected LocationManager mLocationManager

mUpdateMinDistance

protected float mUpdateMinDistance

mUpdateMinTime

protected long mUpdateMinTime

Constructors

GpsEventSource

public GpsEventSource(Context context)

Methods

addListener

public void addListener(GpsEventListener listener)

Add new listener for GPS events. You will likely want to call addListener() from your Activity’s or Fragment’s onResume() method, to enable the features. Remember to call the corresponding removeListener() in your Activity’s or Fragment’s onPause() method, to prevent unnecessary use of the battery.

Параметры:
  • listener – A listener class implements GpsEventListener adding to listeners array

getLastKnownBestLocation

public Location getLastKnownBestLocation()

getLastKnownLocation

public Location getLastKnownLocation()

isBetterLocation

protected boolean isBetterLocation(Location location, Location currentBestLocation)

Determines whether one Location reading is better than the current Location fix

Параметры:
  • location – The new Location that you want to evaluate
  • currentBestLocation – The current Location fix, to which you want to compare the new one

isSameProvider

protected boolean isSameProvider(String provider1, String provider2)

Checks whether two providers are the same

removeListener

public void removeListener(GpsEventListener listener)

Remove listener from listeners of GPS events. You will likely want to call removeListener() from your Activity’s or Fragment’s onPause() method, to prevent unnecessary use of the battery. Remember to call the corresponding addListener() in your Activity’s or Fragment’s onResume() method.

Параметры:
  • listener – A listener class implements GpsEventListener removing from listeners array

updateActiveListeners

public void updateActiveListeners()