Class Vsdk
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic Stringstatic Stringstatic org.json.JSONObjectstatic android.content.Contextstatic Stringstatic voidinit(android.content.Context context, String configPath, androidx.core.util.Consumer<Boolean> onReady) Initializes the SDK with the given applicationContextand configuration path.static booleanChecks whether the Vsdk has been successfully initialized.static voidrelease()Releases all resources held by the Vsdk and its engines.
-
Constructor Details
-
Vsdk
public Vsdk()
-
-
Method Details
-
getVersion
- Returns:
- The current version string of Vsdk.
-
getConfiguration
public static org.json.JSONObject getConfiguration()- Returns:
- The active configuration as a
JSONObject.
-
getConfigPath
- Returns:
- The absolute file path to the current configuration file path.
-
getConfigDirPath
- Returns:
- The absolute file path to the current configuration file directory.
-
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
- Returns:
- The current Android
Contextused 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 applicationContextand configuration path.The provided context must be valid and persist throughout the entire lifecycle of the application. It is strongly recommended to pass an
Applicationcontext rather than anActivitycontext 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
Activitycontext 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
onReadycallback is triggered with the result:trueif initialization was successful,falseotherwise.- 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 receivetrueon success orfalseon failure.- Throws:
Exception- If an error occurs during initialization.
-
release
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.
-