SDKNativeEngine (API Reference)
Class SDKNativeEngine
Holds internal services and configurations needed by various HERE SDK modules.
You can initialize the HERE SDK in two ways:
- Create a shared instance of the
SDKNativeEnginewithSDKNativeEngine.makeSharedInstance(). - Create individual instances of the
SDKNativeEngineviaSDKNativeEngine(). Note that this does not automatically set a shared instance.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum representing a strategy to flush memory caches. -
Constructor Summary
ConstructorsConstructorDescriptionSDKNativeEngine(android.content.Context androidContext, SDKOptions options) Makes a new instance of SDKNativeEngine using supplied options. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear persistent storage for the HERE SDKUsageStats.voidClear cache for the HERE SDKUsageStats.voiddispose()Stops pending requests and closes open files and databases .voidenableUsageStats(boolean enabled) Enable or disableUsageStatsfor the HERE SDK.voidgetDeviceId(DeviceIdCallback callback) The unique identifier assigned to the device for this application.Gets the options used by this instance ofSDKNativeEngine.static ParameterConfigurationGets the configuration for default values of parameters used in the HERE SDK.Gets the pass through features.Gets the current proxy settings.Gets a list of usage statistics for all available HERE SDK features.static SDKNativeEngineGets the shared instance of this SDK engine that can be accessed by any HERE SDK module as the default engine.booleanGets the current offline mode.static voidmakeSharedInstance(android.content.Context androidContext, SDKOptions options) Makes a new instance of this class using the supplied options and stores it as shared instance seegetSharedInstance().voidReleases memory occupied by internal caches.voidsetAccessKeySecret(String accessKeySecret) Overrides HERE SDK access key secret with new value.voidsetAccessScope(String scope) Overrides the token scope of the HERE SDK with new value.voidsetOfflineMode(boolean value) Sets the offline mode.static voidSets the configuration for default values of parameters used in the HERE SDK.voidSets the pass through features.voidsetProxySettings(ProxySettings value) Sets the proxy settings.static voidsetSharedInstance(SDKNativeEngine value) Sets the shared instance of this SDK engine that can be accessed by any HERE SDK module as the default engine.
-
Constructor Details
-
SDKNativeEngine
public SDKNativeEngine(@NonNull android.content.Context androidContext, @NonNull SDKOptions options) throws InstantiationErrorException Makes a new instance of SDKNativeEngine using supplied options.
- Parameters:
androidContext-The Android context
options-The options for the new engine.
- Throws:
InstantiationErrorException-Indicates what went wrong when the instantiation was attempted.
-
-
Method Details
-
setAccessKeySecret
Overrides HERE SDK access key secret with new value. The new credentials will be used for new requests.
Note: This method can be called from any thread. Access key ID can be set with constructor of SDKNativeEngine. New instance of SDKNativeEngine should be used if a new access key ID is required.
- Parameters:
accessKeySecret-New access key secret.
-
setAccessScope
Overrides the token scope of the HERE SDK with new value. A new token will be fetched with the set scope and used for future requests. Setting an empty string will fetch a token for the global scope.
This method can be called from any thread.
- Parameters:
scope-New scope for token
-
dispose
public void dispose()Stops pending requests and closes open files and databases . Dispose signal is sent to dependent modules. Usage of engine, or dependent modules after calling dispose leads to undefined behavior. Please be aware that this method does not clean any type of storage. Note: This method should be called from main thread.
-
enableUsageStats
public void enableUsageStats(boolean enabled) Enable or disable
UsageStatsfor the HERE SDK. Defaults to disabled (false). When enabled,SDKNativeEngine.getSdkUsageStats()returns actual online data consumption. Note that the flag does not cancel pending requests.UsageStatscan be enabled or disabled at any time.Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
- Parameters:
enabled-True, if UsageStats are enabled.
-
clearPersistentUsageStats
public void clearPersistentUsageStats()Clear persistent storage for the HERE SDK
UsageStats. Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process. -
clearUsageStatsCache
public void clearUsageStatsCache()Clear cache for the HERE SDK
UsageStats. Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process. -
purgeMemoryCaches
Releases memory occupied by internal caches. Purging caches reduces memory footprint of application and may temporary reduce performance.
- Parameters:
strategy-Option to control how much memory caches will be purged.
-
getDeviceId
The unique identifier assigned to the device for this application. This device ID is primarily used for tracking Monthly Active Users (MAUs).
- Parameters:
callback-Callback which receives the result on the main thread.
-
getOptions
Gets the options used by this instance of
SDKNativeEngine.- Returns:
Options used by this instance of
SDKNativeEngine.
-
isOfflineMode
public boolean isOfflineMode()Gets the current offline mode.
Sets offline mode for the HERE SDK to offline or online. Defaults to false, which means the HERE SDK uses an online connection. When enabled, this prevents the HERE SDK from initiating any online connection except for provided pass through features if set. See
getPassThroughFeatures(). Note that the flag does not cancel pending requests. The mode can be enabled or disabled at any time. In order to fully operate offline, the mode needs to be enabled viaSDKOptions.offlineMode. Initialization of the HERE SDK itself does not require an internet connection. Returnstrueif the HERE SDK uses offline connection mode, otherwise returnsfalse.Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
- Returns:
The offline mode.
-
setOfflineMode
public void setOfflineMode(boolean value) Sets the offline mode.
Sets offline mode for the HERE SDK to offline or online. Defaults to false, which means the HERE SDK uses an online connection. When enabled, this prevents the HERE SDK from initiating any online connection except for provided pass through features if set. See
getPassThroughFeatures(). Note that the flag does not cancel pending requests. The mode can be enabled or disabled at any time. In order to fully operate offline, the mode needs to be enabled viaSDKOptions.offlineMode. Initialization of the HERE SDK itself does not require an internet connection. Returnstrueif the HERE SDK uses offline connection mode, otherwise returnsfalse.Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
- Parameters:
value-The offline mode.
-
getPassThroughFeatures
Gets the pass through features.
Sets pass through features which are allowed to use online data when HERE SDK is in offline mode. Pass through features can be updated at any time. When offline mode is disabled, existing pass through features will be removed. These needs to be set again when you enable offline mode next time. By default, reporting of HERE SDK
UsageStatswill be enabled when at least one pass-through feature is set.Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
- Returns:
The pass through features.
-
setPassThroughFeatures
Sets the pass through features.
Sets pass through features which are allowed to use online data when HERE SDK is in offline mode. Pass through features can be updated at any time. When offline mode is disabled, existing pass through features will be removed. These needs to be set again when you enable offline mode next time. By default, reporting of HERE SDK
UsageStatswill be enabled when at least one pass-through feature is set.Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
- Parameters:
value-The pass through features.
-
getParameterConfig
Gets the configuration for default values of parameters used in the HERE SDK.
Note: This feature is in beta state and thus there can be bugs and unexpected behavior. Related APIs may change for new releases without a deprecation process.
- Returns:
Configuration for default values of parameters used in the HERE SDK.
-
setParameterConfig
Sets the configuration for default values of parameters used in the HERE SDK.
Note: This feature is in beta state and thus there can be bugs and unexpected behavior. Related APIs may change for new releases without a deprecation process.
- Parameters:
value-Configuration for default values of parameters used in the HERE SDK.
-
getProxySettings
Gets the current proxy settings.
Defaults to (
null), which indicates proxy is not enabled. When setting proxy settings, they will immediately be applied and all the pending and fresh requests will use these settings. Pass (null) to indicate that proxy should be disabled. If proxy is necessary from the start then it's recommended to useNetworkSettings.proxySettingsinSDKOptions.networkSettings.Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
- Returns:
Proxy settings of this SDK engine that will be used by HERE SDK network for all requests.
-
setProxySettings
Sets the proxy settings.
Defaults to (
null), which indicates proxy is not enabled. When setting proxy settings, they will immediately be applied and all the pending and fresh requests will use these settings. Pass (null) to indicate that proxy should be disabled. If proxy is necessary from the start then it's recommended to useNetworkSettings.proxySettingsinSDKOptions.networkSettings.Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
- Parameters:
value-Proxy settings of this SDK engine that will be used by HERE SDK network for all requests.
-
getSdkUsageStats
Gets a list of usage statistics for all available HERE SDK features.
UsageStatshas cache and persistent storage. Reads from the persistent storage happen onSDKNativeEnginecreation step. Writes to persistent storage happen by reaching internal limit (amount of upload bytes, by default is 50KB).Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
- Returns:
Gets a list of usage statistics for all available HERE SDK features.
-