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 SDKNativeEngine with SDKNativeEngine.makeSharedInstance().
  • Create individual instances of the SDKNativeEngine via SDKNativeEngine(). Note that this does not automatically set a shared instance.
  • 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

      public void setAccessKeySecret(@NonNull 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 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 UsageStats for 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. UsageStats can 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 InstantiationErrorException

      Makes 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 call dispose() 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 via SDKOptions.offlineMode. Initialization of the HERE SDK itself does not require an internet connection. Returns true if the HERE SDK uses offline connection mode, otherwise returns false.

      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 via SDKOptions.offlineMode. Initialization of the HERE SDK itself does not require an internet connection. Returns true if the HERE SDK uses offline connection mode, otherwise returns false.

      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 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 UsageStats will 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 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 UsageStats will 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 use NetworkSettings.proxySettings in SDKOptions.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 use NetworkSettings.proxySettings in SDKOptions.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 List<UsageStats> getSdkUsageStats()

      Gets a list of usage statistics for all available HERE SDK features.

      UsageStats has cache and persistent storage. Reads from the persistent storage happen on SDKNativeEngine creation 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.