> For the complete documentation index, see [llms.txt](https://platform-business.gitbook.io/adx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform-business.gitbook.io/adx/zh/android/sdk-integration/initialize.md). Agents can also search and read this documentation through its [MCP server](https://platform-business.gitbook.io/adx/~gitbook/mcp).

# Initialize

### SDK Initialize <a href="#sdk-initialize" id="sdk-initialize"></a>

* 在加载广告之前，请通过调用 `initialize` 初始化 ADX Android SDK。此操作仅需在应用启动时执行一次。
* 创建 `ADXConfiguration` 对象时，请在 `setAppId()` 方法参数中输入您获取的 ADX APP ID，`setGdprType()` 方法参数请使用 `DIRECT_NOT_REQUIRED` 或 `POPUP_LOCATION`。

{% tabs %}
{% tab title="Java" %}

```java
// 创建 ADXConfiguration 对象
  // 如果计划在 EEA（欧洲经济区）地区提供服务，请使用 "POPUP_LOCATION"
  // 如果无计划在 EEA（欧洲经济区）地区提供服务，请使用 "DIRECT_NOT_REQUIRED"
ADXConfiguration adxConfiguration = new ADXConfiguration.Builder()
        .setAppId("<ADX_APP_ID>")
        .setGdprType(ADXConfiguration.GdprType.POPUP_LOCATION)
        .build();
        
// 尝试初始化 ADX SDK
ADXSdk.getInstance().initialize((Activity) this, 
        adxConfiguration, 
        new ADXSdk.OnInitializedListener() {
        @Override
        public void onCompleted(boolean result, ADXGDPR.ADXConsentState adxConsentState) {
                // 广告初始化完成
        }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
// 创建 ADXConfiguration 对象
  // 如果计划在 EEA（欧洲经济区）地区提供服务，请使用 "POPUP_LOCATION"
  // 如果无计划在 EEA（欧洲经济区）地区提供服务，请使用 "DIRECT_NOT_REQUIRED"
val adxConfiguration = ADXConfiguration.Builder()
    .setAppId("<ADX_APP_ID>")
    .setGdprType(ADXConfiguration.GdprType.POPUP_LOCATION)
    .build()
    
// 尝试初始化 ADX SDK
ADXSdk.getInstance().initialize(this as Activity, adxConfiguration) { result, adxConsentState ->
    // 收到初始化完成回调后加载广告
}
```

{% endtab %}
{% endtabs %}
