LocationEngine (API Reference)
Class LocationEngine
- All Implemented Interfaces:
com.here.sdk.location.AppConfigListener,LocationEngineBase
LocationAccuracy or LocationOptions.
Each instance of this class will be using internally the same client providing the actual
location updates. For that reason, only one LocationEngine
can be started at a time. Multiple listeners can be attached, either to receive
location updates, see LocationListener, status updates, see
LocationStatusListener or location issue has occurred, see
LocationIssueListener. When a different LocationAccuracy or LocationOptions is
desired, the LocationEngine needs to be stopped and started again.-
Constructor Summary
ConstructorsConstructorDescriptionConstructor of the LocationEngineLocationEngine(SDKNativeEngine engine) Constructor of the LocationEngine -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds aLocationIssueListenerto the engine to get notified when a location issue has occurredvoidaddLocationListener(LocationListener listener) Adds aLocationListenerto the engine to get notified when there is a newLocation.voidAdds aLocationStatusListenerto the engine to get notified when there is an important status change.By calling this method, the application developer confirms that they have received an exceptional permission from HERE in written form to **not** include a reference to the HERE Privacy Notice.It is the responsibility of the application developer to ensure that the application user is informed about the collection of characteristic information regarding nearby mobile and Wi-Fi network signals.voidDisables access to vehicle's sensor information.voidenableVehicleSensors(androidx.car.app.hardware.CarHardwareManager manager) This feature enables the utilization of the vehicle's GNSS and movement sensor information.Gets the last known location obtained by the engine.booleanChecks if the engine is in started state.voidRemoves aLocationIssueListenerfrom the enginevoidremoveLocationListener(LocationListener listener) Removes aLocationListenerfrom the enginevoidRemoves aLocationStatusListenerfrom the enginesetLastKnownLocationPersistent(boolean persistent) Enables or disables saving of last known location so it persists between application sessions.start(LocationAccuracy locationAccuracy) Starts the location engine with desiredLocationAccuracy.start(LocationOptions locationOptions) Starts the location engine with desiredLocationOptions.voidstop()Stops the location engine.updateLocationAccuracy(LocationAccuracy locationAccuracy) Reconfigures the location engine with desired LocationAccuracy.updateLocationOptions(LocationOptions locationOptions) Reconfigures the location engine with desired LocationOptions.
-
Constructor Details
-
LocationEngine
Constructor of the LocationEngine- Throws:
InstantiationErrorException- if engine was not initialized properly
-
LocationEngine
Constructor of the LocationEngine- Parameters:
engine- of the SDK holding internal services and SDK configuration- Throws:
InstantiationErrorException- if engine was not initialized properly
-
-
Method Details
-
start
Starts the location engine with desiredLocationAccuracy. Make sure to call either confirmHEREPrivacyNoticeInclusion() or confirmHEREPrivacyNoticeException() beforehand.- Specified by:
startin interfaceLocationEngineBase- Parameters:
locationAccuracy- Desired location accuracy- Returns:
- the status of the LocationEngine
- Throws:
IllegalArgumentException- if the argument is null
-
start
Starts the location engine with desiredLocationOptions. Make sure to call either confirmHEREPrivacyNoticeInclusion() or confirmHEREPrivacyNoticeException() beforehand.- Specified by:
startin interfaceLocationEngineBase- Parameters:
locationOptions- Desired location options.- Returns:
- the status of the LocationEngine
- Throws:
IllegalArgumentException- if the argument is null
-
updateLocationAccuracy
@NonNull public LocationEngineStatus updateLocationAccuracy(@NonNull LocationAccuracy locationAccuracy) Reconfigures the location engine with desired LocationAccuracy. This method is a faster way to change location accuracy for already started location engine, than calling
LocationEngineBase.stop()andLocationEngineBase.start(LocationOptions)in sequence. ReturnsLocationEngineStatus.NOT_READY, if called for unstarted location engine.- Specified by:
updateLocationAccuracyin interfaceLocationEngineBase- Parameters:
locationAccuracy-Desired location accuracy. Requested accuracy is not guaranteed.
- Returns:
Engine status. Valid values are defined in
LocationEngineStatus- Throws:
IllegalArgumentException- if the argument is null
-
updateLocationOptions
@NonNull public LocationEngineStatus updateLocationOptions(@NonNull LocationOptions locationOptions) Reconfigures the location engine with desired LocationOptions. This method is a faster way to change location options for already started location engine, than calling
LocationEngineBase.stop()andLocationEngineBase.start(LocationOptions)in sequence. ReturnsLocationEngineStatus.NOT_READY, if called for unstarted location engine.- Specified by:
updateLocationOptionsin interfaceLocationEngineBase- Parameters:
locationOptions-Desired location options.
- Returns:
Engine status. Valid values are defined in
LocationEngineStatus- Throws:
IllegalArgumentException- if the argument is null
-
stop
public void stop()Stops the location engine.- Specified by:
stopin interfaceLocationEngineBase
-
isStarted
public boolean isStarted()Checks if the engine is in started state.- Specified by:
isStartedin interfaceLocationEngineBase- Returns:
- true if started, false otherwise
-
confirmHEREPrivacyNoticeInclusion
It is the responsibility of the application developer to ensure that the application user is informed about the collection of characteristic information regarding nearby mobile and Wi-Fi network signals. Additionally, a link to the related HERE Privacy Notice must be made available to the user.
This information can be included in the application's Terms & Conditions, Privacy Policy, or otherwise made accessible to the user.
An example text for informing users about the data collection: "This application uses location services provided by HERE Technologies. To maintain, improve, and provide these services, HERE Technologies occasionally collects characteristic information about nearby mobile and Wi-Fi network signals. For more information, please refer to the HERE Privacy Notice at: https://legal.here.com/here-network-positioning-via-sdk"
By calling this method, the application developer confirms that this information is made available to the end user. For example, it is sufficient to inform users once that using the app requires acceptance of its terms (if any). Then, in the terms include the above mentioned data collection information and a link to the related HERE Privacy Notice. The user is not required to open the terms to acknowledge the data collection details. The "Positioning" example app on GitHub provides an example of this. When the above criteria are met, it is recommended to silently execute this method each time before starting the
LocationEngine, as failure to do so will result in the engine being non-functional.- Specified by:
confirmHEREPrivacyNoticeInclusionin interfaceLocationEngineBase- Returns:
Immediately returns with
ConfirmationStatus.OK.
-
confirmHEREPrivacyNoticeException
By calling this method, the application developer confirms that they have received an exceptional permission from HERE in written form to **not** include a reference to the HERE Privacy Notice. As a result, the
LocationEnginewill not collect characteristic information about the nearby mobile and Wi-Fi network signals. However, the engine will still be fully functional and it will deliver location updates when the exception can be confirmed.Note that this call should not involve user interaction and it should be executed silently by the application before starting the
LocationEngine.The permission for exceptional use will be verified asynchronously using your HERE SDK credentials. A missing permission will lead to stopping of the
LocationEngineandLocationEngineStatus.PRIVACY_NOTICE_UNCONFIRMEDis delivered toLocationStatusListener.- Specified by:
confirmHEREPrivacyNoticeExceptionin interfaceLocationEngineBase- Returns:
- Confirmation action status. Valid values are defined in
ConfirmationStatus. A first-time call may result inConfirmationStatus.PENDING, make sure to use theLocationStatusListenerto get notified on an unconfirmed permission.
-
enableVehicleSensors
public void enableVehicleSensors(@NonNull androidx.car.app.hardware.CarHardwareManager manager) This feature enables the utilization of the vehicle's GNSS and movement sensor information. It is recommended to always enable this feature by default when the application supports Android Auto. This allows the phone's positioning sensor information to be augmented with the vehicle's sensor data, resulting in the best possible positioning estimates. However, given the varying quality of car sensor implementations, it is also advisable to provide application users with the option to disable the usage of vehicle sensor information - this would be helpful in case the vehicle reports information that is clearly misleading or contradictory. Furthermore, users should be able to re-enable this feature if the vehicle's capability improves.- Specified by:
enableVehicleSensorsin interfaceLocationEngineBase- Parameters:
manager- Android Auto car hardware manager.
-
disableVehicleSensors
public void disableVehicleSensors()Disables access to vehicle's sensor information.- Specified by:
disableVehicleSensorsin interfaceLocationEngineBase
-
getLastKnownLocation
Gets the last known location obtained by the engine.- Specified by:
getLastKnownLocationin interfaceLocationEngineBase- Returns:
- last known
Locationif available, null if never obtained.
-
addLocationListener
Adds aLocationListenerto the engine to get notified when there is a newLocation.- Specified by:
addLocationListenerin interfaceLocationEngineBase- Parameters:
listener- The listener to be added- Throws:
IllegalArgumentException- if the listener is null
-
removeLocationListener
Removes aLocationListenerfrom the engine- Specified by:
removeLocationListenerin interfaceLocationEngineBase- Parameters:
listener- The listener to be removed- Throws:
IllegalArgumentException- if the listener is null
-
addLocationStatusListener
Adds aLocationStatusListenerto the engine to get notified when there is an important status change.- Specified by:
addLocationStatusListenerin interfaceLocationEngineBase- Parameters:
listener- The listener to be added- Throws:
IllegalArgumentException- if the listener is null
-
removeLocationStatusListener
Removes aLocationStatusListenerfrom the engine- Specified by:
removeLocationStatusListenerin interfaceLocationEngineBase- Parameters:
listener- The listener to be removed- Throws:
IllegalArgumentException- if the listener is null
-
addLocationIssueListener
Adds aLocationIssueListenerto the engine to get notified when a location issue has occurred- Specified by:
addLocationIssueListenerin interfaceLocationEngineBase- Parameters:
listener- The listener to be added- Throws:
IllegalArgumentException- if the listener is null
-
removeLocationIssueListener
Removes aLocationIssueListenerfrom the engine- Specified by:
removeLocationIssueListenerin interfaceLocationEngineBase- Parameters:
listener- The listener to be removed- Throws:
IllegalArgumentException- if the listener is null
-
setLastKnownLocationPersistent
Enables or disables saving of last known location so it persists between application sessions. Defaults to enabled.- Specified by:
setLastKnownLocationPersistentin interfaceLocationEngineBase- Parameters:
persistent- If true enables last known location to be saved persistently, or if false disables it.- Returns:
- LocationEngineStatus.OK always.
-