How to use NetworkSettings class to override system DNS settings

How to use NetworkSettings class to override system DNS settings

The NetworkSettings class in the HERE SDK is responsible for configuring network-related parameters during the initialization of the SDKNativeEngine. This class enables developers to customize the SDK's network behavior, ensuring optimal stability and performance across various network environments.

Customer/developer can use NetworkSettings.domainNameSystemServers to override system DNS settings to force SDK to use customized DNS to resolve domain names, example as below:

<br /> private void initializeHERESDK() { // Set your credentials for the HERE SDK. String accessKeyID = BuildConfig.HERE_ACCESS_KEY_ID; String accessKeySecret = BuildConfig.HERE_ACCESS_KEY_SECRET; AuthenticationMode authenticationMode = AuthenticationMode.withKeySecret(accessKeyID, accessKeySecret); SDKOptions options = new SDKOptions(authenticationMode); InetSocketAddress inetSocketAddress = new InetSocketAddress("8.8.8.8", 53); //Specify DNS IP and port number NetworkEndpoint networkEndpoint = new NetworkEndpoint(inetSocketAddress.getAddress()); List networkEndpointList = List.of(networkEndpoint); NetworkSettings networkSettings = new NetworkSettings(); networkSettings.domainNameSystemServers = networkEndpointList; options.networkSettings = networkSettings; try { Context context = this; SDKNativeEngine.makeSharedInstance(context, options); } catch (InstantiationErrorException e) { throw new RuntimeException("Initialization of HERE SDK failed: " + e.error.name()); } }<br />

Here is the demo of using NetworkSettings to utilize DNS 8.8.8.8 to override a invalid system DNS which blocks all intenet traffic.