# \[Android]KARTE独自のカスタムURLスキームをハンドリングできるようにする

KARTE SDKでは、下記の各種機能に対応するために、カスタムURLスキームをハンドリングできるようにする設定が必要です。

* [Native機能呼び出し](https://support.karte.io/post/1F1VeY2yy3mrTIO2U4HhHi)
* [ビジュアルトラッキング](https://support.karte.io/post/7JbUVotDwZMvl6h3HL9Zt7)
* [アプリで確認](https://support.karte.io/post/3VsAULpSA8GmHwHXRHlB2O#2-7) の機能を使ったアクションのプレビュー

ここでは、カスタムURLスキームの設定方法について記載します。

※launchMode に "singleTop" などを指定したActivityではintentが更新されないため、カスタムURLスキームのハンドリングが正しく動作しない可能性があります。このような場合での対応方法については[再開されるActivityに対応する](https://app.developers.karte.io/android-sdk-appendix/appendix-relaunch-activity-android-sdk) をご確認ください。

## カスタムURLスキームを設定する

任意のエディタで `AndroidManifest.xml` を開き、下記設定を追記します。

{% code title="AndroidManifest.xml" overflow="wrap" %}

```xml
<activity
          android:name=".XxxActivity"
          android:theme="@style/Theme.AppCompat.NoActionBar">

  <!-- 任意のActivityに対して、以下の指定を行なってください -->
  <intent-filter >
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="krt-$(APIキー)" />
  </intent-filter>
</activity>
```

{% endcode %}

なお `$(APIキー)` の部分には、KARTEプロジェクト毎に用意されているAPIキーを指定します。

{% hint style="info" %}
**APIキーの確認方法**

APIキーは管理画面から取得可能です。\
詳細については、[こちら](https://support.karte.io/post/7bq63EfIXdTjcHXextXKBh)をご覧ください。
{% endhint %}

{% hint style="warning" %}
**間違いやすい点**

SDKの初期化に利用するアプリケーションキーとAPIキーは異なるものです。\
お間違えないようご注意ください。
{% endhint %}


---

# 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://app.developers.karte.io/android-sdk-appendix/concepts-custom-url-scheme-android-sdk.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.
