Android SDK
Add live in-app micro-surveys to your Android app. The SDK fetches your published survey config, listens to your analytics events, evaluates triggers on the device, and shows the right survey at the right time as a native bottom sheet or centered card, with no per-survey code in your app.
Beta. The Android SDK is new. The APIs below are stable; expect small changes as it’s hardened.
The SDK is on Maven Central as ai.microsurveys:microsurveys-android, with
Amplitude support in ai.microsurveys:microsurveys-amplitude. Source lives at
MicroSurveysAI/microsurveys-android .
Requirements
- Android 6.0+ (
minSdk23), AndroidX. Kotlin or Java. - Your app doesn’t need to use Compose; Views apps work the same.
- A project API key from the dashboard (
ms_live_…/ms_test_…), the same key your iOS and web apps use.
1. Add the dependency
In your app module’s build.gradle.kts:
dependencies {
implementation("ai.microsurveys:microsurveys-android:0.1.0")
// Only if you use Amplitude:
implementation("ai.microsurveys:microsurveys-amplitude:0.1.0")
}Use the newest version from the
releases page .
The SDK adds the INTERNET permission and its own R8 rules, so there’s nothing to
add to your manifest or ProGuard file.
2. Start it in Application.onCreate
Kotlin
import ai.microsurveys.MicroSurveys
import ai.microsurveys.amplitude.amplitudePlugin
class JuniperApp : Application() {
lateinit var microSurveys: MicroSurveys
override fun onCreate() {
super.onCreate()
microSurveys = MicroSurveys(this, apiKey = "ms_live_xxx")
amplitude.add(microSurveys.amplitudePlugin()) // forward events + identity
microSurveys.start() // load config, send anything queued
}
}Keep one instance for the app’s lifetime.
amplitudePlugin()returns an Amplitude enrichment plugin. It reads each event, plus Amplitude’s current user id, device id and user properties, and returns the event unchanged: it never alters or drops your analytics.start()uses the cached config at once (so surveys work offline and on the first screen), sends anything queued while offline, and refreshes the config. After that the SDK refreshes on its own when the app comes back to the foreground with a config older than 12 hours.
3. Optional configuration
Without Amplitude, or extra context
ms.setUser("user-123", mapOf("plan" to "pro")) // identity + audience properties
ms.track("checkout_completed", mapOf("cart_size" to 3))track feeds the same trigger engine as the Amplitude plugin, so you can use
either or both. Call setUser at each launch and when the user signs in: the id
lasts for the app session, while user properties are kept across launches.
Control where surveys appear
Surveys show over the activity that last came to the foreground. To hold them back on some screens, or pick another activity:
ms.presentationAnchor = ActivityProvider { if (onCheckout) null else currentActivity }Returning null skips showing for now; the live debugger
reports it as “no screen to present on”.
Theming
Survey appearance is configured in the dashboard and delivered in the config; the SDK applies it automatically, in light or dark to match the app. See the Dashboard guide. Fonts are fetched at runtime and never bundled.
Debug logging
MicroSurveys.loggingEnabled = true // on by default in debuggable buildsFilter Logcat by the MicroSurveys tag (adb logcat -s MicroSurveys) to see
events, each trigger decision (and why a survey didn’t show), presentation,
config fetches and uploads.
How a published survey reaches the screen
You publish a survey
In the dashboard, with a trigger (e.g. checkout_completed where
cart_size > 2) plus eligibility rules and a theme.
The SDK downloads config
GET /api/sdk/config returns all active surveys and the project theme; the SDK
caches it on the device.
Each event is matched locally
Every Amplitude event (or ms.track(...)) is checked against every active
survey’s trigger. When a trigger is satisfied, the SDK applies the
eligibility order: window → trigger → frequency →
audience → sampling → cap.
An eligible survey is shown
After delaySeconds (the cap is checked again then), over the activity on
screen, in your dashboard theme. It stays up through rotation and folding, and
the back button closes it unless the survey is required. One survey shows at a
time.
Results are reported
The SDK posts an impression as soon as the survey appears, and marks it
dismissed if it’s closed without an answer. If answered, it posts a
response. Both carry a UUID clientId and wait in a small on-device queue:
a failed send is retried every few seconds and when the app returns to the
foreground, so answers given offline arrive as soon as the device is back online.
Trigger progress, occurrence counters and last-shown timestamps persist per user across app restarts.
endUserId resolves as Amplitude user id → device id → setUser id → a
generated, persisted anonymous id.
Next
- API reference — the exact config, impression, and response shapes.
- Concepts — triggers, targeting, sampling, and caps in depth.