Getting started
This guide will help you set up the Ada Android SDK in your app. The process involves two main steps:
- Install the SDK: Add the SDK manually to your project.
- Launch Ada: Choose one of the available options to display Ada, such as XML, programmatic setup, dialog, or activity.
Follow the instructions below to install the SDK and start integrating Ada into your app!
Install Android SDK
-
Get the Android SDK
.aarfile here.To download the AAR file:
- Click on the package you need (e.g.,
android-sdk,android-sdk-appcompat, orandroid-sdk-appcompat-legacy) - Select your desired version from the versions list
- In the Files section, click on the
.aarfile to download it
- Click on the package you need (e.g.,
-
To install the library, save the
.aarfile under your app module libs folder (for example “MyAwesomeProject/app/libs”), and include*.aarin the application-levelbuild.gradlefile.
- Synchronize the project.
You can also import an .aar file using Android Studio. First, download the versioned .aar, and then simply define the implementation for the new local library module.
Note that if the android-sdk-appcompat-<version_number>.aar or the android-sdk-appcompat-legacy-<version_number>.aar is used, then the dependency declaration must resemble the following, with the appcompat libraries depending on the android-sdk library.
Install via Maven Central
Alternatively, you can install the Ada Android SDK directly from Maven Central Repository. Add the following dependency to your app-level build.gradle file:
Standard SDK
Legacy SDK
For projects that require the legacy version:
Replace <version> with the latest version number available on Maven Central.
Make sure your project’s build.gradle file includes mavenCentral() in the repositories block:
After adding the dependency, synchronize your project to download and integrate the SDK.
Launch 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.
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).
Programmatically
To programmatically create the chat frame, create a view object and pass context to the constructor.
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.
Then show it using the native Android show method.
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.
You can use “AdaEmbedActivity” as a regular Android activity. For example, flags and actions can be added.
File Upload Support
If your implementation uses Zendesk live agent support, file uploads might require a few additional steps, based on your chosen method for launching the SDK.
AdaEmbedActivity and AdaEmbedDialog already have this functionality, but if you work directly with AdaEmbedView you must handle uploads as described below.
- Set up a callback to
AdaEmbedView. This callback will be fired when a user makes a request to attach a file. - Once you get the URI, invoke
filePickerCallback.onFileTaken(someUri). This will signal toAdaEmbedViewthat the file is ready to attach. It’s also possible to passnull, which will cancel the request.
This operation doesn’t require you to pass the file URI to callback immediately. You can save filePickerCallback and invoke the callback later (for example, taking the URI via file picker).
To notify AdaEmbedView that you are going to handle file attachments, you should return true.