# Initialize

### init(Context)

Initialization PubStar SDK. Initialization must be called once before loading or showing ads.

### Event

`InitAdListener`

| Callback  | Function                                                 |
| --------- | -------------------------------------------------------- |
| `onDone`  | call when PubStar SDK initializes successfully           |
| `onError` | call when load ad failed. return object type `ErrorCode` |

### Example

```kotlin

PubStarAdManager.getInstance()
    .setInitAdListener(object : InitAdListener {
        override fun onDone() {
            // callback when init done (ready to call load and show ad)
        }

        override fun onError(code: ErrorCode) {
            // callback when init error
        }
    }).init(context)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pub-star.gitbook.io/docs/1.3.1/android-sdk/initialize.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
