> For the complete documentation index, see [llms.txt](https://app.developers.karte.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://app.developers.karte.io/android-sdk-appendix/appendix-optout-android-sdk.md).

# \[Android]オプトアウトに対応する

KARTE SDKによるユーザーの行動データ収集や各種アクションの配信（アプリ内メッセージ等）を無効にしたい場合はオプトアウト機能を利用してください。

オプトアウト時に制限される機能については[KARTE for App SDKのオプトアウト](https://support.karte.io/post/4QmpYqEwJplN2VeVBWGjZk#2-0)を御覧ください。

## 初期状態を設定する

Configクラスの `isOptOut` 値を設定することで、SDK初期化時点での初期状態を設定することが可能です。\
以下の例では、SDKの初期化時点ではオプトアウト状態となります。

{% tabs %}
{% tab title="Kotlin" %}
{% code title="YourApplication.kt" overflow="wrap" %}

```kotlin
override fun onCreate() {
  super.onCreate()
  val config = Config.build { isOptOut = true }
  KarteApp.setup(this, "アプリケーションキー", config)
}
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code title="YourApplication.java" overflow="wrap" %}

```java
@Override
public void onCreate() {
  super.onCreate();
  Config config = new Config.Builder().isOptOut(true).build();
  KarteApp.setup(this, "アプリケーションキー", config);
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## オプトインする

`optIn` メソッドを呼び出すことで、オプトイン状態にすることが可能です。

{% tabs %}
{% tab title="Kotlin" %}
{% code overflow="wrap" %}

```kotlin
KarteApp.optIn()
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code overflow="wrap" %}

```java
KarteApp.optIn();
```

{% endcode %}
{% endtab %}
{% endtabs %}

## オプトアウトする

`optOut` メソッドを呼び出すことで、オプトアウト状態にすることが可能です。

{% tabs %}
{% tab title="Kotlin" %}
{% code overflow="wrap" %}

```kotlin
KarteApp.optOut()
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code overflow="wrap" %}

```java
KarteApp.optOut();
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
**optIn/optOut後の次回起動時の挙動について**

`optIn` および `optOut` メソッドを呼び出した場合、その情報は端末内に保存され、次回初期化時にも保存した設定に基づき動作します。
{% endhint %}


---

# 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://app.developers.karte.io/android-sdk-appendix/appendix-optout-android-sdk.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.
