Class Vsdk

java.lang.Object
com.vivoka.vsdk.Vsdk

public class Vsdk extends Object
Vsdk is a static utility class providing access to configuration, paths, context, and initialization lifecycle.

Typical usage:


 Vsdk.init(context, "/path/to/config.json", isReady -> {
     if (isReady) {
         // SDK is initialized and ready to use
     }
 });
 
  • Constructor Details

    • Vsdk

      public Vsdk()
  • Method Details

    • getVersion

      public static String getVersion()
      Returns:
      The current version string of Vsdk.
    • getConfiguration

      public static org.json.JSONObject getConfiguration()
      Returns:
      The active configuration as a JSONObject.
    • getConfigPath

      public static String getConfigPath()
      Returns:
      The absolute file path to the current configuration file path.
    • getConfigDirPath

      public static String getConfigDirPath()
      Returns:
      The absolute file path to the current configuration file directory.
    • getCacheDirPath

      public static String getCacheDirPath()
      Returns:
      The absolute path to the cache directory.
    • isInitialized

      public static boolean isInitialized()
      Checks whether the Vsdk has been successfully initialized.
      Returns:
      True if the Vsdk is initialized, false otherwise.
    • getContext

      public static android.content.Context getContext() throws Exception
      Returns:
      The current Android Context used to initialize the Vsdk.
      Throws:
      Exception - If the Vsdk is not initialized.
    • init

      public static void init(android.content.Context context, String configPath, androidx.core.util.Consumer<Boolean> onReady) throws Exception
      Initializes the SDK with the given application Context and configuration path.

      The provided context must be valid and persist throughout the entire lifecycle of the application. It is strongly recommended to pass an Application context rather than an Activity context to avoid memory leaks or unexpected behavior.

      This context is required for the proper functioning of the Vsdk, as the Vsdk will rely on it for resources, configuration, and various runtime operations. If the context is invalidated or destroyed (for example, if it is an Activity context that gets destroyed), the Vsdk may become unusable, leading to errors or crashes.

      Therefore, it is critical that the provided context is valid throughout the app's lifecycle, typically by using the application context. Once the SDK is initialized, you should ensure that the context remains accessible for all Vsdk operations.

      Once initialization completes, the onReady callback is triggered with the result: true if initialization was successful, false otherwise.

      Parameters:
      context - The application context must be (must remain valid for the app's lifetime).
      configPath - The path to the configuration file.
      onReady - A callback that will receive true on success or false on failure.
      Throws:
      Exception - If an error occurs during initialization.
    • release

      public static void release() throws Exception
      Releases all resources held by the Vsdk and its engines. After calling this method, the Vsdk must be re-initialized before use. All engines that were initialized will also be released.
      Throws:
      Exception - If an error occurs during release.