public abstract class LocationProviderAdapter
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
LocationProviderAdapter.LocationAcquisitionListener
Callback for when the device's location has been determined.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
mAreLocationUpdatesRunning |
Constructor and Description |
---|
LocationProviderAdapter() |
Modifier and Type | Method and Description |
---|---|
void |
acquireLocation(LocationProviderAdapter.LocationAcquisitionListener listener,
long maximumAge,
float maximumInaccuracy)
Acquire the current location, and will implicitly initiate requests for (future) location updates.
|
void |
addLocationListener(LocationListener listener)
Adds a listener that is called when a location update is received.
|
protected abstract void |
cancelLocationUpdates() |
void |
deinitialize()
Deinitializes the adapter.
|
protected long |
determineLocationAge(Location location)
A convenience for determining how much time has elapsed since the given update's timestamp.
|
abstract Location |
getLastKnownLocation() |
protected boolean |
hasListeners() |
void |
initialize()
Initialize the adapter.
|
protected void |
notifyListenersLocationChanged(Location location)
Called by an implementation when an update has been received from its underlying location
provider.
|
void |
removeLocationListener(LocationListener listener)
Removes the given listener.
|
abstract void |
requestLocationUpdates() |
public void initialize()
The base implementation of this method takes no action and is intended to be overridden by
subclasses that need to do work that can't be done on demand. For example,
a PlayLocationProviderAdapter (uses PlayServices) connects to a Service, which can't be done
synchronously, preventing it from being done lazily from a method like
getLastKnownLocation()
.
public void deinitialize()
public void addLocationListener(LocationListener listener)
public abstract void requestLocationUpdates()
public void removeLocationListener(LocationListener listener)
listener
- The listener to remove.protected abstract void cancelLocationUpdates()
protected boolean hasListeners()
protected void notifyListenersLocationChanged(Location location)
public abstract Location getLastKnownLocation()
determineLocationAge(Location)
.protected long determineLocationAge(Location location)
public void acquireLocation(LocationProviderAdapter.LocationAcquisitionListener listener, long maximumAge, float maximumInaccuracy)