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
.aar
file here. - To install the library, save the
.aar
file under your app module libs folder (for example “MyAwesomeProject/app/libs”), and include*.aar
in the application-levelbuild.gradle
file.
- 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.
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 toAdaEmbedView
that 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
.