> 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-iam-spec-android-sdk.md).

# \[Android]アプリ内メッセージの表示の仕組み

アプリ内メッセージの表示にはWebViewを利用しています。\
このため管理画面上で、HTML / CSS / JavaScript をカスタマイズすることでアプリケーションのコードを変更することなく、アクションの見た目を変更することが可能となっています。

![アプリ内メッセージ表示のイメージ](/files/8Wb6boJJTsk0HusZSNlG)

## WebViewのライフサイクル

WebViewは、SDKが初期化されるタイミングで生成されメモリ上に保持されます。

アクションの表示が必要となった場合、SDKはWebViewを含むViewを生成し、アプリケーション上に `WindowManager.addView` メソッドを通じてWindowとして配置します。

WebView上のアクションが非表示になると、ViewはWindowManagerから削除され、WebViewは再びメモリ上で保持されます。

## WebViewのキャッシュ

初期設定ではWebViewは、アクションを表示するためのViewとは別に生成され、メモリ上にキャッシュされます。

WebViewはアクションを表示するためのViewとともに生成されます。\
WebView上のアクションが非表示になると、親Viewが破棄されるタイミングで同時に破棄されます。

## Windowの表示レベル

SDKが生成する Window の type は [TYPE\_APPLICATION\_ATTACHED\_DIALOG](https://developer.android.com/reference/android/view/WindowManager.LayoutParams#TYPE_APPLICATION_ATTACHED_DIALOG)としています。

{% hint style="warning" %}
**アプリ内メッセージが表示されないとき**

アプリ内メッセージを表示しているWindowの表示レベルよりも、上位に以下のような別のViewが表示されている場合、うまく表示されない場合があります。

* Alert Dialog などの Dialog あるいは DialogFragment
* 独自に追加しているWindow等

アプリ内メッセージよりDialog, DialogFragment等が上位に表示される場合、Dialog, DialogFragment等のWindowのtypeをKARTE側と同じ`TYPE_APPLICATION_ATTACHED_DIALOG`に設定いただくことで、アプリ内メッセージを上位に表示させるような対応は可能です。\
※ただしDialog, DialogFragment等よりアプリ内メッセージが後から表示される場合を想定しています
{% 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-iam-spec-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.
