> For the complete documentation index, see [llms.txt](https://docs.nubrick.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nubrick.app/reference/android/events.md).

# Events

### NubrickEvent

{% hint style="info" %}
送信された `NubrickEvent` は Nubrick サーバーへ送信されます。
{% endhint %}

`NubrickEvent` は `NubrickSDK.dispatch(...)` で送信するアプリイベントです。

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

```kotlin
NubrickSDK.dispatch(NubrickEvent("<TRIGGER_EVENT_NAME>"))
```

{% endtab %}

{% tab title="Java" %}

```java
NubrickSDK.dispatch(new NubrickEvent("<TRIGGER_EVENT_NAME>"));
```

{% endtab %}
{% endtabs %}

### Event

`Event` は、埋め込みコンポーネント内のアクション発生時に `onEvent` で受け取るイベントです。

```kotlin
data class Event(
    val name: String?,
    val deepLink: String?,
    val payload: List<EventProperty>?
)

data class EventProperty(
    val name: String,
    val value: String,
    val type: EventPropertyType
)

enum class EventPropertyType {
    INTEGER,
    STRING,
    TIMESTAMPZ,
    UNKNOWN
}
```

`onEvent` は `Config(onEvent = ...)`、`NubrickSDK.Embedding(...)`、`RemoteConfigVariant.GetAsEmbedding(...)` などで設定できます。

### Java のイベントリスナー <a href="#java" id="java"></a>

SDK 内のコンポーネントで発生した `Event` は `NubrickGlobalEventListener`、`NubrickSDK.dispatch(...)` で送信した `NubrickEvent` は `NubrickDispatchListener` で受け取れます。Java では、`Application` の `onCreate` で `NubrickSDK.createConfig(...)` を呼び出し、それぞれのリスナーを設定します。

```java
import app.nubrick.nubrick.Config;
import app.nubrick.nubrick.NubrickSDK;

Config config = NubrickSDK.createConfig(
    "<YOUR_PROJECT_ID>",
    event -> {
        String name = event.getName();
        String deepLink = event.getDeepLink();
        System.out.println("Event: " + name + ", deepLink: " + deepLink);
    },
    event -> System.out.println("Dispatched: " + event.getName()),
    true
);
NubrickSDK.initialize(this, config);
```

特定の `NubrickEmbeddingView` で発生したイベントだけを受け取る場合は、`setOnEventListener(...)` に `NubrickEventListener` を設定します。

```java
import app.nubrick.nubrick.view.NubrickEmbeddingView;

NubrickEmbeddingView embeddingView = findViewById(R.id.nubrick_embedding);
embeddingView.setOnEventListener(event -> {
    System.out.println("Embedding event: " + event.getName());
});
```

`Event` の各プロパティは `getName()`、`getDeepLink()`、`getPayload()` で取得できます。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.nubrick.app/reference/android/events.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
