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

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

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

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.

Last updated