> For the complete documentation index, see [llms.txt](https://docs.hello-lisa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hello-lisa.com/developers/guides/integration-guide/app-integration/android/communication.md).

# Communication

This guide explains how to establish seamless bidirectional communication between your Android app and the LiSA Player running within a WebView. By leveraging native-to-JavaScript bridges and WebView event listeners, you can enable your Android app and the LiSA Player to exchange data, trigger events, and synchronize state in real time.

Whether you need to send commands from you app to the LiSA Player (e.g., changing app behavior or updating content) or pass data from the WebView back to your app (e.g., user actions or analytics), this guide will walk you through the necessary setup and best practices for efficient, secure, and reliable communication.

### Receiving Messages

To receive messages from the LiSA Player In your Android app, use `addJavascriptInterface`:

```kotlin
// Add JavaScript interface to handle messages from the web app
webView.addJavascriptInterface(WebAppInterface(), "MessageFromLiSA")
```

```kotlin
private class WebAppInterface {
    @android.webkit.JavascriptInterface
    fun postMessage(message: String) {
        println("Message received from LiSA: $message")
        // Process the JSON message here
    }
}
```

* The `WebAppInterface` is registered under the name `MessageFromLiSA`.
* When the LiSA Player sends a message using `window.MessageFromLiSA.postMessage`, the `postMessage` function in the interface processes it.
* You can handle the JSON message inside the `postMessage` method.

***

### Sending messages

Use the `evaluateJavascript` method in Kotlin to send a message to the web app:

```kotlin
webView.evaluateJavascript("""
    window.postMessage(JSON.stringify({ type: 'event', payload: { key: 'value' } }));
""", null)
```


---

# 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.hello-lisa.com/developers/guides/integration-guide/app-integration/android/communication.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.
