The Ada Android SDK is a small framework that you can use to embed your Ada chatbot into your native Android application.

It also supports actions and settings that you can use to customize the behavior of your bot. For example, you might want to set the bot language, or customize the greeting. The Android SDK reference covers these options and more.

Quick start for Android

You can install the the Ada Adroid SDK manually or using Gradle.

Install Android SDK manually

  1. Get the Android SDK .aar file here.
// build.gradle
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
  1. To install the library, save the .aar file under your app module libs folder, for example MyAwesomeProject/app/libs, and include *.aar in application level build.gradle file.
  2. Synchronize the project.

👍

You can also import a file using Android Studio. Go to File -> New -> New Module. Select Import .JAR/.AAR Package and click Next. Specify the path to the .aar file and the module name, then click Finish.

// build.gradle
implementation project(':new_module_name')

Finally, define the implementation for the new local library module.

Install Android SDK using Gradle

  1. Get the latest Ada Android SDK package from the Ada Support Gitlab repository. Choose support/ada/embed/android-sdk unless one of the following is true:

    • If your project has artifacts within the AndroidX namespace, use implementation 'support.ada.embed:android-sdk-appcompat:1.3.9'
    • If your project uses Android Support Library, use implementation 'support.ada.embed:android-sdk-appcompat-legacy:1.3.9'

    The appcompat packages allow you to use use newer Android API features on older devices.

  2. To integrate the SDK, first add the following code to the project level build.gradle file.

// build.gradle
allprojects {
    repositories {
        maven {
            url "https://gitlab.com/api/v4/projects/25892134/packages/maven"
        }
    }
}
  1. Add the dependency to the application-level build.gradle.

Launch Ada

After installing the Android SDK, there are a few ways to start Ada:

XML

The simplest way to start Ada chat is via XML, as in the following example. You must replace my-bot with the actual name of your bot, and modify any other relevant as needed.

<!-- XML -->
<support.ada.embed.widget.AdaEmbedView
        android:id="@+id/ada_chat_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:ada_handle="my-bot" />

To display the view, the ada_handle parameter is required. If you specify it as an attribute, the chat is displayed immediately upon attachment to the parent view. If it is not specified, then you can do it later programmatically, using the method initialize(settings: AdaEmbedView.Settings).

// Delayed initialization
val adaView = findViewById(R.id.ada_chat_frame)

adaSettings = AdaEmbedView.Settings.Builder("ada-example")
    .build()
adaView.initialize(adaSettings)

Programmatically

To programmatically create the chat frame, create a view object and pass context to the constructor.

val adaView = AdaEmbedView(getContext())

val adaSettings = AdaEmbedView.Settings.Builder("ada-example")
    .build()
adaView.initialize(adaSettings)

After this, the view will be created, but will not be initialized. To do this, call initialize(settings: AdaEmbedView.Settings), passing the settings object as an argument.

Finally, to display the newly created chat frame on screen, simply add the view to your container.

Dialog

To display a separate chat window on top of the current window, you can use AdaEmbedDialog.

First, create a dialog object and pass the settings to its arguments using a constant, AdaEmbedDialog.ARGUMENT_SETTINGS.

val dialog = AdaEmbedDialog()
 adaDialog.arguments = Bundle().apply {
    putParcelable(AdaEmbedDialog.ARGUMENT_SETTINGS, settings)
 }

Then show it using the native Android show method.

dialog.show(supportFragmentManager, AdaEmbedDialog.TAG)

📘

TAG is a simple class name, you can use any value you want.

Activity

Use AdaEmbedActivity to open the chat in a separate window attached to the app navigation.

To do this, create an Intent, and put the settings in it with the key AdaEmbedActivity.EXTRA_SETTINGS, then run the activity.

val intent = Intent(context, AdaEmbedActivity::class.java)
intent.putExtra(AdaEmbedActivity.EXTRA_SETTINGS, settings)
context.startActivity(intent)

📘

You can use "AdaEmbedActivity" as a regular Android activity. For example, flags and actions can be added.