Class SDKNativeEngine
Class SDKNativeEngine
- java.lang.Object
-
- com.here.NativeBase
-
- com.here.sdk.core.engine.SDKNativeEngine
-
public final class SDKNativeEngine extends NativeBase
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.
- Create a shared instance of the
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSDKNativeEngine.PurgeMemoryStrategyEnum representing a strategy to flush memory caches.
-
Constructor Summary
Constructors Constructor Description SDKNativeEngine(android.content.Context androidContext, SDKOptions options)Makes a new instance of SDKNativeEngine using supplied options.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearPersistentUsageStats()Clear persistent storage for the HERE SDKUsageStats.voidclearUsageStatsCache()Clear 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.SDKOptionsgetOptions()Gets the options used by this instance ofSDKNativeEngine.static ParameterConfigurationgetParameterConfig()Gets the configuration for default values of parameters used in the HERE SDK.java.util.Set<PassThroughFeature>getPassThroughFeatures()Gets the pass through features.ProxySettingsgetProxySettings()Gets the current proxy settings.java.util.List<UsageStats>getSdkUsageStats()Gets a list of usage statistics for all available HERE SDK features.static SDKNativeEnginegetSharedInstance()Gets the shared instance of this SDK engine that can be accessed by any HERE SDK module as the default engine.booleanisOfflineMode()Gets 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().voidpurgeMemoryCaches(SDKNativeEngine.PurgeMemoryStrategy strategy)Releases memory occupied by internal caches.voidsetAccessKeySecret(java.lang.String accessKeySecret)Overrides HERE SDK access key secret with new value.voidsetAccessScope(java.lang.String scope)Overrides the token scope of the HERE SDK with new value.voidsetOfflineMode(boolean value)Sets the offline mode.static voidsetParameterConfig(ParameterConfiguration value)Sets the configuration for default values of parameters used in the HERE SDK.voidsetPassThroughFeatures(java.util.Set<PassThroughFeature> value)Sets 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 Detail
-
SDKNativeEngine
public SDKNativeEngine(@NonNull android.content.Context androidContext, @NonNull SDKOptions options) throws InstantiationErrorExceptionMakes 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 Detail
-
setAccessKeySecret
public void setAccessKeySecret(@NonNull java.lang.String accessKeySecret)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
public void setAccessScope(@NonNull java.lang.String scope)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.
-
makeSharedInstance
public static void makeSharedInstance(@NonNull android.content.Context androidContext, @NonNull SDKOptions options) throws InstantiationErrorExceptionMakes a new instance of this class using the supplied options and stores it as shared instance see
getSharedInstance(). If there was a previously shared instance then it's disposed (so there is no need to calldispose()on app side) before the new instance is created.Note: The HERE SDK is not guaranteed to be thread safe and it is required to make calls to the SDK - including this one - from the main thread.
- Parameters:
androidContext-The Android context
options-The options for the new engine.
- Throws:
InstantiationErrorException-Indicates what went wrong when the instantiation was attempted.
-
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
public void purgeMemoryCaches(@NonNull SDKNativeEngine.PurgeMemoryStrategy strategy)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
public void getDeviceId(@NonNull DeviceIdCallback callback)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
@NonNull public SDKOptions getOptions()
Gets the options used by this instance of
SDKNativeEngine.- Returns:
Options used by this instance of
SDKNativeEngine.
-
getSharedInstance
@Nullable public static SDKNativeEngine getSharedInstance()
Gets the shared instance of this SDK engine that can be accessed by any HERE SDK module as the default engine.
This is automatically set as a part of the SDK initialization process.
- Returns:
Shared instance of this SDK engine that can be accessed by any HERE SDK module as the default engine.
-
setSharedInstance
public static void setSharedInstance(@Nullable SDKNativeEngine value)Sets the shared instance of this SDK engine that can be accessed by any HERE SDK module as the default engine.
This is automatically set as a part of the SDK initialization process.
- Parameters:
value-Shared instance of this SDK engine that can be accessed by any HERE SDK module as the default engine.
-
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
@Nullable public java.util.Set<PassThroughFeature> 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
public void setPassThroughFeatures(@Nullable java.util.Set<PassThroughFeature> value)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
@NonNull public static ParameterConfiguration 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
public static void setParameterConfig(@NonNull ParameterConfiguration value)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
@Nullable public ProxySettings 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
public void setProxySettings(@Nullable ProxySettings value)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
@NonNull public java.util.List<UsageStats> 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.
-
-