Class AndroidCAresInitializer

java.lang.Object
com.here.sdk.core.engine.AndroidCAresInitializer

public final class AndroidCAresInitializer extends Object
Android-specific entry point for initializing the native c-ares library.

This class is responsible for providing Android's ConnectivityManager to the native c-ares initialization code. On Android, c-ares needs access to ConnectivityManager in order to resolve DNS servers correctly.

The actual CAresInitializer instance is owned and stored on the C++ side as a process-wide global object. This Java class does not own a native handle and does not manage native object lifetime directly.

Typical usage:

 AndroidCAresInitializer.initialize(context);
 

The initialization should be performed once, early in the application or test process lifecycle, before any network or DNS requests are started.

  • Method Details

    • initialize

      public static void initialize(@NonNull android.content.Context context)
      Initializes native c-ares support for Android.

      This method obtains ConnectivityManager from the provided Android Context and passes it to the native c-ares initialization code.

      If c-ares has already been initialized on the native side, this method is expected to be a no-op.

      Parameters:
      context - Android context used to access ConnectivityManager. The application context is preferred, but any valid context with access to Context.CONNECTIVITY_SERVICE can be used.
      Throws:
      IllegalStateException - if ConnectivityManager cannot be obtained from the provided context.
      RuntimeException - if native c-ares initialization fails.