Skip to content

initSDK ​

Initialize the SDK ​

Initializes the SUDOP SDK. After successful initialization, continue with authentication (auth) and game startup (startGame).


Method Declaration ​

java
/**
 * Initialize the SDK
 *
 * @param context  context
 * @param appId    appId
 * @param appKey   appKey
 * @param privacyConfig Optional advertising privacy configuration
 * @param listener Callback listener
 */
public static void initSDK(Context context, String appId, String appKey, SUDOPInitSDKListener listener);
public static void initSDK(Context context, String appId, String appKey,
                           SUDOPPrivacyConfig privacyConfig,
                           SUDOPInitSDKListener listener);

Parameters ​

1. SUDOPInitSDKParams ​

Configures the base environment required for SDK initialization:

FieldTypeDescription
contextContextRequired. It is recommended to use ApplicationContext to avoid memory leaks.
appIdStringRequired. The unique application identifier applied for on the SUD platform.
appKeyStringRequired. The application key applied for on the SUD platform.
privacyConfigSUDOPPrivacyConfigOptional confirmed advertising privacy states. null means the SDK does not actively set them.

2. SUDOPInitSDKListener ​

Receives the asynchronous callback for the initialization result:

  • void onSuccess(): The SDK base environment has been initialized. You can proceed to authentication (auth).
  • void onFailure(int retCode, String retMsg): Initialization failed. Troubleshoot parameters or network issues based on the error code.

Example Code ​

java
// Read the user's confirmed choices from the host's CMP/consent flow first.
// Values below illustrate syntax, not defaults or a recommendation to grant consent.
// Each argument may be null: do not actively set that state. Null is not withdrawal.
SUDOPPrivacyConfig privacyConfig = SUDOPPrivacyConfig.builder()
        // GDPR consent: GRANTED = granted; DENIED = denied or withdrawn.
        // NOT_APPLICABLE = not applicable; this field is not set.
        .setGdprConsentStatus(SUDOPPrivacyConfig.GdprConsentStatus.NOT_APPLICABLE)
        // Sale/sharing opt-out: OPTED_OUT = user opted out; NOT_OPTED_OUT = did not opt out.
        // NOT_APPLICABLE = not applicable. Opted out is not the same as granting consent.
        .setDoNotSellStatus(SUDOPPrivacyConfig.DoNotSellStatus.NOT_APPLICABLE)
        // Brazil LGPD consent: GRANTED = granted; DENIED = denied or withdrawn.
        // NOT_APPLICABLE = not applicable. Set independently of the GDPR field.
        .setLgpdConsentStatus(SUDOPPrivacyConfig.LgpdConsentStatus.NOT_APPLICABLE)
        // Age treatment: CHILD = child; TEEN = teen treatment, not child treatment.
        // UNSPECIFIED explicitly requests unspecified age treatment; null does not set it.
        .setAgeRestrictedTreatment(SUDOPPrivacyConfig.AgeRestrictedTreatment.UNSPECIFIED)
        .build();

SUDOP.initSDK(context, "YOUR_APP_ID", "YOUR_APP_KEY", privacyConfig, new SUDOPInitSDKListener() {
    @Override
    public void onSuccess() {
        // SDK initialized successfully
        Log.i("SUDOP", "SDK initialized successfully.");
    }

    @Override
    public void onFailure(int retCode, String retMsg) {
        // Initialization failed
        Log.e("SUDOP", "SDK init failed: " + retMsg + " (Code: " + retCode + ")");
    }
});

Notes ​

  • When to call: It is recommended to call this during Application.onCreate() or when the main Activity starts.
  • Call frequency: Typically initialize once during the App lifecycle.
  • Lifecycle: Successful initialization is a prerequisite for calling the auth and startGame series of interfaces.
  • Compatible overload: The original overload without privacyConfig remains available and is equivalent to passing null.
  • Compliance boundary: Use privacy states already confirmed by the host. The SDK does not determine legal applicability, display consent dialogs, or replace a CMP. See SUDOPPrivacyConfig for the field definitions.