> For the complete documentation index, see [llms.txt](https://integrations.quack.ai/BKUZmzGN2Mmipf4UROTF/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://integrations.quack.ai/BKUZmzGN2Mmipf4UROTF/mobile/adding-quack-ai-to-your-android-app.md).

# Adding Quack AI to your Android App

There are plenty of resources online about adding a WebView to Android so this guide will focus primarily on what to put in your WebView!

### Step 1: Add the Webview to your Layout <a href="#step-1-add-the-webview-to-your-layout" id="step-1-add-the-webview-to-your-layout"></a>

Go to your app's layout file (e.g., `activity_main.xml`) in the `res/layout` folder. Then, add the WebView Widget. For example:

```
<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
```

### Step 2: Configure your Activity <a href="#step-2-configure-your-activity" id="step-2-configure-your-activity"></a>

**Open the Java/Kotlin Activity File**: For example, `MainActivity.java` or `MainActivity.kt` Then, initialize WebView:

* Java:

```
javaCopy codeWebView myWebView = (WebView) findViewById(R.id.webview);
```

* In Kotlin:

```
kotlinCopy codeval myWebView: WebView = findViewById(R.id.webview)
```

Finally, point the Webview to your unique URL that contains your mobile chat AI

```
myWebView.loadUrl("https://m.thequack.ai/sdk/<YOUR_TOKEN>");
```

### Step 3: Pass in Metadata <a href="#step-3-pass-in-metadata" id="step-3-pass-in-metadata"></a>

You may pass in arbitrary, unique information about the user as metadata by adding URL params to the URL. This metadata will be saved along with each conversation. User ID is what unique identifies a user and allows conversation history to be saved across sessions. For example:

```
myWebView.loadUrl("https://m.thequack.ai/sdk/<YOUR_TOKEN>?userId=...&email=...");
```

That's it! You may find more in-depth guides on adding WebViews in Android on the internet if you need further assistance.


---

# 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://integrations.quack.ai/BKUZmzGN2Mmipf4UROTF/mobile/adding-quack-ai-to-your-android-app.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.
