Class LocationDataSource
- java.lang.Object
-
- com.esri.arcgisruntime.location.LocationDataSource
-
- Direct Known Subclasses:
NmeaLocationDataSource
,SimulatedLocationDataSource
public abstract class LocationDataSource extends Object
An abstract data source that provides location updates to the associated MapView's LocationDisplay.- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
LocationDataSource.ErrorChangedEvent
An event that is invoked whenthe error property
changes.static interface
LocationDataSource.ErrorChangedListener
The listener interface for receivingerror changed events
from a LocationDataSource.class
LocationDataSource.HeadingChangedEvent
An event representing the change of the heading of a LocationDataSource.static interface
LocationDataSource.HeadingChangedListener
The listener interface for receiving heading changed events from a LocationDataSource.static class
LocationDataSource.Location
A location update provided by a LocationDataSource, consisting primarily of aPoint
representing a geographical location, and attributes of location change such as the course (direction of travel), and the velocity (speed of location change).class
LocationDataSource.LocationChangedEvent
An event representing the change of the location of a LocationDataSource.static interface
LocationDataSource.LocationChangedListener
The listener interface for receiving location changed events from a LocationDataSource.static class
LocationDataSource.Status
The enumeration of possible LocationDataSource statuses.class
LocationDataSource.StatusChangedEvent
An event representing the change of the status of a LocationDataSource.static interface
LocationDataSource.StatusChangedListener
The listener interface for receiving status changed events from a LocationDataSource.
-
Constructor Summary
Constructors Constructor Description LocationDataSource()
Creates a default LocationDataSource, and sets up the status changed listeners.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addErrorChangedListener(LocationDataSource.ErrorChangedListener listener)
Registers the given listener to be called when theerror property
has changed.void
addHeadingChangedListener(LocationDataSource.HeadingChangedListener listener)
Registers the given listener to be called when the heading has changed.void
addLocationChangedListener(LocationDataSource.LocationChangedListener listener)
Registers the given listener to be called when the location has changed.void
addStartedListener(Runnable listener)
Deprecated.as of 100.14.0, use the ListenableFuture returned fromstartAsync()
or theStatusChangedListener
to get notified when the LocationDataSource has started.void
addStatusChangedListener(LocationDataSource.StatusChangedListener listener)
Registers the given listener to be called when the status has changed.Throwable
getError()
Gets an error that describes a problem encountered while starting or running theLocationDataSource
.LocationDataSource.Status
getStatus()
Gets the status of the LocationDataSource.boolean
isStarted()
Deprecated.as of 100.14.0, usegetStatus()
to check if the LocationDataSource has started.protected abstract void
onStart()
Called fromstartAsync()
.protected void
onStartCompleted(Throwable throwable)
Sets the result status of the starting process, and any error generated during it.protected abstract void
onStop()
Called from thestopAsync()
orstop()
method, subclasses should perform any necessary clean-up in this method; for example, stop streaming the location data, release resources, and so on.boolean
removeErrorChangedListener(LocationDataSource.ErrorChangedListener listener)
Unregisters the given listener that was previously added usingaddErrorChangedListener(ErrorChangedListener)
.boolean
removeHeadingChangedListener(LocationDataSource.HeadingChangedListener listener)
Unregisters the given listener that was previously added usingaddHeadingChangedListener(HeadingChangedListener)
.boolean
removeLocationChangedListener(LocationDataSource.LocationChangedListener listener)
Unregisters the given listener that was previously added usingaddLocationChangedListener(LocationChangedListener)
.boolean
removeStartedListener(Runnable listener)
Deprecated.as of 100.14.0, useaddStatusChangedListener(StatusChangedListener)
to get notified when the LocationDataSource has started.boolean
removeStatusChangedListener(LocationDataSource.StatusChangedListener listener)
Unregisters the given listener that was previously added usingaddStatusChangedListener(StatusChangedListener)
.protected void
setLastKnownLocation(LocationDataSource.Location location)
Sets the last known Location, which will be displayed as soon as the data source has been started, until a new location update is received.ListenableFuture<Void>
startAsync()
Asynchronously initializes the location data source and prepares to begin receiving location updates.void
stop()
Deprecated.as of 100.14.0, usestopAsync()
instead.ListenableFuture<Void>
stopAsync()
Stop the location data source asynchronously.protected void
updateHeading(double heading)
Called when the data source has a new heading value.protected void
updateLocation(LocationDataSource.Location location)
Called when the data source has new location information.
-
-
-
Method Detail
-
startAsync
public final ListenableFuture<Void> startAsync()
Asynchronously initializes the location data source and prepares to begin receiving location updates. Calls theonStart()
method of a subclass.- Returns:
- a ListenableFuture indicating when the LocationDataSource has started.
- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
-
addStartedListener
@Deprecated public final void addStartedListener(Runnable listener)
Deprecated.as of 100.14.0, use the ListenableFuture returned fromstartAsync()
or theStatusChangedListener
to get notified when the LocationDataSource has started.Registers the given Runnable to be called when the location data source has successfully started, or has failed to start. The Runnable is called immediately if this location data source has already started (isStarted()
is true).You can also use LocationDisplay.addDataSourceStatusChangedListener(LocationDisplay.DataSourceStatusChangedListener)} in order to be notified when the LocationDataSource associated with a LocationDisplay starts or stops.
This listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
listener
- a Runnable to be called when the location data source has started- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
- See Also:
removeStartedListener(Runnable)
-
removeStartedListener
@Deprecated public final boolean removeStartedListener(Runnable listener)
Deprecated.as of 100.14.0, useaddStatusChangedListener(StatusChangedListener)
to get notified when the LocationDataSource has started.Unregisters the given Runnable that was previously added usingaddStartedListener(Runnable)
.- Parameters:
listener
- the Runnable to unregister- Returns:
- true if the Runnable was removed successfully; false otherwise
- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
-
addLocationChangedListener
public final void addLocationChangedListener(LocationDataSource.LocationChangedListener listener)
Registers the given listener to be called when the location has changed.This listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
listener
- a listener to be called when the location has changed- Throws:
IllegalArgumentException
- if listener is null- Since:
- 100.6.0 for Android and 100.9.0 for Java SE
- See Also:
removeLocationChangedListener(LocationChangedListener)
-
removeLocationChangedListener
public final boolean removeLocationChangedListener(LocationDataSource.LocationChangedListener listener)
Unregisters the given listener that was previously added usingaddLocationChangedListener(LocationChangedListener)
.- Parameters:
listener
- the listener to unregister- Returns:
- true if the listener was removed successfully; false otherwise
- Since:
- 100.6.0 for Android and 100.9.0 for Java SE
-
addHeadingChangedListener
public final void addHeadingChangedListener(LocationDataSource.HeadingChangedListener listener)
Registers the given listener to be called when the heading has changed.This listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
listener
- a listener to be called when the heading has changed- Throws:
IllegalArgumentException
- if listener is null- Since:
- 100.6.0 for Android and 100.9.0 for Java SE
- See Also:
removeHeadingChangedListener(HeadingChangedListener)
-
removeHeadingChangedListener
public final boolean removeHeadingChangedListener(LocationDataSource.HeadingChangedListener listener)
Unregisters the given listener that was previously added usingaddHeadingChangedListener(HeadingChangedListener)
.- Parameters:
listener
- the listener to unregister- Returns:
- true if the listener was removed successfully; false otherwise
- Since:
- 100.6.0 for Android and 100.9.0 for Java SE
-
addStatusChangedListener
public final void addStatusChangedListener(LocationDataSource.StatusChangedListener listener)
Registers the given listener to be called when the status has changed.This listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
listener
- a listener to be called when the status has changed- Throws:
IllegalArgumentException
- if listener is null- Since:
- 100.6.0 for Android and 100.9.0 for Java SE
- See Also:
removeStatusChangedListener(StatusChangedListener)
-
removeStatusChangedListener
public final boolean removeStatusChangedListener(LocationDataSource.StatusChangedListener listener)
Unregisters the given listener that was previously added usingaddStatusChangedListener(StatusChangedListener)
.- Parameters:
listener
- the listener to unregister- Returns:
- true if the listener was removed successfully; false otherwise
- Since:
- 100.6.0 for Android and 100.9.0 for Java SE
-
addErrorChangedListener
public final void addErrorChangedListener(LocationDataSource.ErrorChangedListener listener)
Registers the given listener to be called when theerror property
has changed.This listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
listener
- a listener to be called when the error has changed- Throws:
IllegalArgumentException
- if listener is null- Since:
- 100.14.0
- See Also:
removeErrorChangedListener(ErrorChangedListener)
-
removeErrorChangedListener
public final boolean removeErrorChangedListener(LocationDataSource.ErrorChangedListener listener)
Unregisters the given listener that was previously added usingaddErrorChangedListener(ErrorChangedListener)
.- Parameters:
listener
- the listener to unregister- Returns:
- true if the listener was removed successfully; false otherwise
- Since:
- 100.14.0
-
getError
public final Throwable getError()
Gets an error that describes a problem encountered while starting or running theLocationDataSource
.This property is used to notify the user about errors that occur in
LocationDataSource
. Such errors are critical forLocationDataSource
and will cause it to stop. IfLocationDataSource
cannot be started, or it stopped after a successful start, this property will store information related to what causedLocationDataSource
to stop.- Returns:
- an error that describes a problem encountered while starting or running the LocationDataSource, or null if none
- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
-
getStatus
public final LocationDataSource.Status getStatus()
Gets the status of the LocationDataSource.- Returns:
- the current status of the LocationDataSource
- Since:
- 100.14.0
-
onStartCompleted
protected final void onStartCompleted(Throwable throwable)
Sets the result status of the starting process, and any error generated during it. This method must be called by the subclass once the location data source has finished its starting process.- Parameters:
throwable
- the error generated during the starting process, or null if it started successfully- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
-
setLastKnownLocation
protected final void setLastKnownLocation(LocationDataSource.Location location)
Sets the last known Location, which will be displayed as soon as the data source has been started, until a new location update is received.The last known location may not accurately represent the true current location, but indicates to the user that the LocationDataSource is waiting for updated location data. It will be displayed using the LocationDisplay.getAcquiringSymbol().
- Parameters:
location
- the last known location
-
onStart
protected abstract void onStart()
Called fromstartAsync()
. Subclasses should implement this method to prepare for starting the data source. TheonStartCompleted(Throwable)
method must be called by the subclass once the location data source has finished its starting process.- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
-
stop
@Deprecated public final void stop()
Deprecated.as of 100.14.0, usestopAsync()
instead.Stops the LocationDataSource. This method will call theonStop()
method implementation of the subclass.- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
-
stopAsync
public final ListenableFuture<Void> stopAsync()
Stop the location data source asynchronously. This method will call theonStop()
method implementation of the subclass.- Returns:
- a ListenableFuture indicating when the LocationDataSource has stopped.
- Since:
- 100.14.0
-
onStop
protected abstract void onStop()
Called from thestopAsync()
orstop()
method, subclasses should perform any necessary clean-up in this method; for example, stop streaming the location data, release resources, and so on.- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
-
updateHeading
protected final void updateHeading(double heading)
Called when the data source has a new heading value. The LocationDisplay.getHeading() associated with this LocationDataSource will be updated with this value and any HeadingChangedListener added will also be notified.- Parameters:
heading
- the heading angle, in degrees clockwise, relative to north- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
-
updateLocation
protected final void updateLocation(LocationDataSource.Location location)
Called when the data source has new location information. The LocationDisplay.getLocation() associated with this LocationDataSource will be updated with this value and any LocationChangedListener added will also be notified.- Parameters:
location
- the updated Location- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
- See Also:
LocationDataSource.Location
-
isStarted
@Deprecated public final boolean isStarted()
Deprecated.as of 100.14.0, usegetStatus()
to check if the LocationDataSource has started.Indicates if this location data source has started successfully. A startedLocationDataSource
is one that is receiving location updates.- Returns:
- true if the data source has started successfully; false otherwise
- Since:
- 100.0.0 for Android and 100.9.0 for Java SE
-
-