The Survicate Mobile SDK for Android allows you to survey specific groups of your mobile app users to understand their needs, expectations, and objections. This SDK is actively maintained by Survicate.
For detailed guidance, refer to the developer docs. If you're looking for the iOS version, visit here.
- Minimum SDK version: 21+
- Compile SDK version: 34+
To use this SDK, you need an account at survicate.com. Sign up for free and locate your workspace key in the Settings.
Define Survicate's Maven repository in the top-level build.gradle file:
allprojects {
repositories {
// ...
maven { url 'https://repo.survicate.com' }
}
}or in the settings.gradle
dependencyResolutionManagement {
// ...
repositories {
// ...
maven { url 'https://repo.survicate.com' }
}
}Then add the SDK dependency to your app's build.gradle file:
dependencies {
// ...
implementation 'com.survicate:survicate-sdk:{version}'
}For other installation methods visit our developer docs.
Add workspace key to your AndroidManifest.xml file:
<application
android:name=".MyApp"
>
<!-- ... -->
<meta-data android:name="com.survicate.surveys.workspaceKey" android:value="YOUR_WORKSPACE_KEY"/>
</application>Initialize the SDK in the Application class:
import android.app.Application
import com.survicate.surveys.Survicate
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
Survicate.init(this)
}
}Survicate lets you easily display targeted surveys to users directly within your app. In the Survicate Panel you can choose criteria that your users have to meet in order for the surveys to appear.
Available conditions:
- Screen
- Event
- User attributes
- Device language
- Operating system
- Screen orientation
A survey can appear when your application user is viewing a specific screen. As an example, a survey can be triggered to show up on the home screen of the application, after a user spends more than 10 seconds there. To enable this behavior, you need to notify the SDK when the user enters and leaves a screen, and set up a screen trigger with delay in the Survicate Panel.
class MainActivity : Activity() {
val SCREEN_NAME = "home"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// ...
Survicate.enterScreen(SCREEN_NAME)
}
override fun onDestroy() {
super.onDestroy()
Survicate.leaveScreen(SCREEN_NAME)
}
}In Jetpack Compose
const val SCREEN_NAME = "home"
@Composable
fun HomeScreen() {
DisposableEffect(Unit) {
Survicate.enterScreen(SCREEN_NAME)
onDispose {
Survicate.leaveScreen(SCREEN_NAME)
}
}
}Log custom events to display surveys with a matching Event Trigger. Events can be invoked with or without additional properties:
button.setOnClickListener {
// event without properties
Survicate.invokeEvent("userPressedPurchase")
// event with properties
val eventProperties = mapOf(
"property1" to "value1",
"property2" to "value2"
)
Survicate.invokeEvent("userPressedPurchase", eventProperties)
}Assign custom attributes to users. These can be used to trigger surveys based on your Audience settings or to filter answers in the Survicate Panel.
// set a single trait
val trait = UserTrait("user_id", "YourUserID")
Survicate.setUserTrait(trait)
// or multiple traits at once
val textTrait = UserTrait("my_custom_attribute", "some value")
val numberTrait = UserTrait("age", 18)
val booleanTrait = UserTrait("subscription_active", true)
val dateTrait = UserTrait("purchase_date", Date())
val traits = listOf(
textTrait,
numberTrait,
booleanTrait,
dateTrait
)
Survicate.setUserTraits(traits)Traits are cached in SharedPreferences, so you don't need to provide them on every app start. For example, set the user_id once at login rather than on each initialization.
You can also update traits at any time, which could trigger a survey.
By default, the SDK uses the device locale (Locale.getDefault()) to determine the survey language and apply locale-based targeting.
If your app supports custom language settings, you can override the locale with:
Survicate.setLocale("en")Accepted values should follow the IETF BCP 47 format:
- Language only, e.g.,
es,fr - Language + region, e.g.,
en-US,pt-BR - Three-letter codes, e.g.,
haw,yue(only for locales without two-letter equivalents)
The locale setting is not persisted across sessions - you should call it after each SDK initialization.
Register a SurvicateEventListener to receive callbacks for the following events:
- Survey displayed
- Question answered
- Survey closed
- Survey completed
val listener = object : SurvicateEventListener() {
override fun onSurveyDisplayed(event: SurveyDisplayedEvent) {
// ...
}
override fun onQuestionAnswered(event: QuestionAnsweredEvent) {
// ...
}
override fun onSurveyClosed(event: SurveyClosedEvent) {
// ...
}
override fun onSurveyCompleted(event: SurveyCompletedEvent) {
// ...
}
}
// Register the listener (e.g. in Activity's onCreate method)
Survicate.addEventListener(listener)
// Remove the listener when no longer needed (e.g. in onDestroy)
Survicate.removeEventListener(listener) Use reset() to simplify testing. This method clears all user data stored on the device — including views, traits, and answers — as well as any in-memory cache.
Survicate.reset()Note that this method is not indended for use in production code.
👋 If you bump into any problems or need more support, contact us at hello@survicate.com