Add in-app support to an Android app
Give your Android app a "Get help" button that shares your app's screen with your support team, with consent, under your company's name.
Give your Android app a "Get help" button: your customer taps it and agrees, and your support team sees your app's screen in the GaiaDesk console — and, if you allow it, guides it — without the customer installing anything.
GaiaDesk's Android SDK is an AAR, net.gaiadesk:embed-android 0.1.0: a Kotlin API that works from Android Views and Jetpack Compose, on Android 8.0 (API 26) or later. The Kotlin sources are open source (MIT), at github.com/Gaia-Desk/gaiadesk-embed-android. The AAR carries the same signed native library, libgaiadesk_embed.so, as GaiaDesk's other embed SDKs; the library is a prebuilt binary that ships, unmodified, inside your app. The React Native and Flutter SDKs use this SDK on Android.
What your customer sees
One button. Your app shows "Get help" wherever you put it.
A consent dialog. It names your company, says what will be shared (this app's screen, or the whole screen if you chose it) and whether your team will be able to guide it. Nothing is shared until the customer agrees.
An indicator for as long as anything is shared. "Sharing with Acme · Stop", drawn by the SDK at the top of your activity, following your customer from activity to activity. In a guided session it also has Pause control.
A support code. Nine digits your customer can read to an agent over the phone.
When the session ends — the customer presses Stop, your app stops it, the session expires, or the app quits — sharing stops at once and nothing is left behind: the SDK installs nothing and writes nothing to disk.
What your support team sees
Agents open Support in the GaiaDesk console, see the waiting customer (with the details your backend passed) and join, or type the support code. Only your own account and team can join, and only team members with a support seat.
1. Add the SDK
The AAR is attached to the v0.1.0 release on GitHub. Put it in your app module's libs/:
mkdir -p app/libs
curl -L -o app/libs/embed-android-0.1.0.aar \
https://github.com/Gaia-Desk/gaiadesk-embed-android/releases/download/v0.1.0/embed-android-0.1.0.aar// app/build.gradle.kts
android {
defaultConfig {
minSdk = 26
}
}
dependencies {
implementation(files("libs/embed-android-0.1.0.aar"))
}The release also carries SHA256SUMS, to check the download. The SDK's only dependency is the Kotlin standard library, which a Kotlin app already has. Its ProGuard rules and its manifest entries (the INTERNET permission, and the activity and service used only for whole-screen sharing) come with the AAR.
net.gaiadesk:embed-android is not on Maven Central yet. Once it is, the dependency becomes implementation("net.gaiadesk:embed-android:0.1.0"). Until then, an Android library module of yours cannot re-publish the local AAR: add it to your app module.
2. The native library
There is nothing else to fetch. The AAR includes libgaiadesk_embed.so for arm64-v8a, armeabi-v7a and x86_64, and Gradle packages it into your APK or App Bundle with the rest of your app.
3. Create the session on your backend
The Android SDK takes an embed token: your backend creates the session with a secret API key (scope support), decides who may get help, passes verified customer details, and hands the app only the token:
curl -s -X POST https://api.gaiadesk.net/v1/support/sessions \
-H "Authorization: Bearer $GAIADESK_API_KEY" -H "Content-Type: application/json" \
-d '{"mode": "view", "customer": {"name": "Ada", "plan": "pro"}}'The response carries embed_token (gdemb_…), which your app passes to the SDK as embedToken. Never ship the secret key in your app: the embed token is all it needs. Version 0.1.0 has no publishable-key option. The full request is in the support API reference.
4. Add the button
import android.app.Activity
import android.util.Log
import android.view.View
import net.gaiadesk.embed.GaiaDeskEmbed
import net.gaiadesk.embed.GaiaDeskEmbedException
class Help(private val activity: Activity, private val cardView: View) {
private var session: GaiaDeskEmbed? = null
// Call on the main thread, from the activity to share.
fun getHelp(embedToken: String, onCode: (String) -> Unit) {
GaiaDeskEmbed.requestConsent(activity, "Acme") { consent ->
if (consent == null) return@requestConsent // the customer said no
try {
session = GaiaDeskEmbed.start(
activity,
GaiaDeskEmbed.Configuration(embedToken, "Acme", maskedViews = listOf(cardView)),
consent,
) { e ->
when (e) {
is GaiaDeskEmbed.Event.Code -> onCode(e.code) // read it to the agent
is GaiaDeskEmbed.Event.Ended -> { session = null }
else -> {}
}
}
} catch (e: GaiaDeskEmbedException) {
Log.w("help", "could not start: ${e.code} ${e.message}")
}
}
}
fun stopHelp() {
session?.stop()
}
}requestConsent shows an AlertDialog with the right wording and gives you a Consent, or null when the customer declines. start needs that consent: the library refuses a session that differs from what the customer agreed to (another company, another capture, guided when they were asked about view-only), and each consent starts one session, within 10 minutes. With your own dialog, call GaiaDeskEmbed.recordConsent(company, guided, capture) when the customer agrees, and say exactly that in it.
Events arrive on the main thread: State, Code(code, sessionId, mode), Joined(agent), Left, Control(allowed), Action(action, applied, reason), Error(code, message) and Ended(reason) — always last, with stopped, app_stopped, disconnected, expired or error. One session runs at a time: a second start throws GaiaDeskEmbedException with code busy.
| |
|---|---|
|
|
| Shown on the consent dialog and the indicator |
| Default |
|
|
| 1 to 30 (default 15) |
| Regions masked from the first frame, in window pixels ( |
|
|
| Views masked wherever they are, measured with every frame |
Your name, colour and logo
The consent dialog and the indicator show the company you pass. Version 0.1.0 of the Android SDK has no colour or logo options.
Guided sessions
By default your team can only look. To let them tap, scroll and type, create the session as cobrowse ("mode": "cobrowse") and ask for and pass guided = true — both ends must want it:
GaiaDeskEmbed.requestConsent(activity, "Acme", guided = true) { consent -> /* … */ }
GaiaDeskEmbed.Configuration(embedToken, "Acme", guided = true)The agent's clicks become taps, scrolling becomes a mouse-wheel scroll, and typing becomes key events, all dispatched to your resumed activity's own window, inside your process: never through the system's input stream, and with no accessibility service. A request outside your window, on a mask, on the indicator, or while none of your activities is in front with focus is refused. Typing never goes to a password field or a masked field. Your customer can pause control from the indicator, and only they can resume it; your app can pause too (setPaused(true)) and resume its own pause. Every request is reported as an Action event.
Keeping things private
Your app's window only. By default the SDK copies your activity's window (PixelCopy): no permission, no system dialog, nothing outside your app. Dialogs and popups shown in windows of their own are not in the picture, and nothing is sent while such a window has focus.
Masks. List sensitive views — card numbers, balances — in
maskedViews(orsetMaskedViewslater). They are painted black before a frame is encoded, from the very first frame, and follow their views as they move. PasswordEditTexts are masked without being listed. Masks fail closed: if your window cannot be located, during a rotation, and for 300 ms after the masks or your window move, the whole picture is blacked out.Jetpack Compose. Compose text fields are not Views, so pass their rects (
boundsInWindow()fromonGloballyPositioned) asmaskedRectsor withsetMaskedRects. While any mask is set, guided typing is refused in a Compose screen;setSecretFocus(true)/setSecretFocus(false)tells the SDK when focus enters and leaves a secret field instead.Protected windows stay protected. A window with
FLAG_SECUREis never captured: the agent sees black and is told the screen is protected.Consent every time. The library refuses to start without it; there is no setting that skips the consent or hides the indicator.
What each platform supports
Capture | Guided input | Consent dialog | |
|---|---|---|---|
Android 8.0 or later (API 26; arm64-v8a, armeabi-v7a, x86_64) | your app's window; the whole screen opt-in | yes, inside your app |
|
Sharing the whole screen is opt-in: capture = Capture.SCREEN (and capture = Capture.SCREEN in requestConsent, so the dialog says so). It uses MediaProjection, so Android shows its own consent after yours and its own casting indication, and a foreground service runs while the screen is shared. Declare in your app's manifest:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />Without them, starting fails with capture_failed. Masks still apply to your own window's regions, and guided input still lands only in your app. A rotation pauses the picture until the orientation returns.
What is and is not permitted
You may: ship the prebuilt library unmodified inside your app, with its licence in your app's notices; offer support sessions to your own customers; show your company's name on the dialog and indicator.
You may not: modify, decompile or re-sign the library separately from your app; hide or imitate the indicator; start a session without your customer's agreement.
See the SDK's README for every option, event and error code, and in-app support for the other platforms.