Android
Blitzllama's Android SDK works with both Kotlin and Java applications, and supports API 21 (Android 5.0) and above. The complete SDK integration into an Android app takes averagely 15 mins.
The three main sections here are:
- Integrating the SDK: retrieving and adding the SDK to your project
- Managing Users: creating a new user and setting user attributes
- Adding Triggers: add triggers in critical components inside your app to initiate the micro-surveys
We recommend using AppCompatActivity while using the SDK, otherwise the surveys won't show up.
HomeActivity extends AppCompatActivity{
}
dependencies {
implementation 'com.blitzllama:Blitzllama:1.7.9'
}
Add Java 8 support to your project (if not added already)
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// For Kotlin projects
kotlinOptions {
jvmTarget = "1.8"
}
}
In the manifest, add the INTERNET Permission and the API_KEY (inside the application tag), which can be found in the Settings page on the Blitzllama dashboard.
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<application>
<meta-data android:name="blitz_api_key"
android:value="API_KEY" /> />
</application>
If using minSdk below 21, you can override the library in your main AndroidManifest.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk tools:overrideLibrary="com.blitzllama.androidSDK" />
...
Create a custom Application if you don't have one. Register the Application class you created in the
AndroidManifest.xml
as follows and make sure that your Application class extends "BlitzLlamaSDK". i.e. the Application class of Blitzllama SDK.<application
android:name=".<name of the application class>"
NOTE: If you are registering the activity lifecycle in your application class, please make sure to call the SDK's init function below that.
You are required to initialize Blitzllama SDK in your Application class using
onCreate()
function. To do this you need to pass the context to the init method.Java
Kotlin
@Override
public void onCreate() {
super.onCreate();
BlitzLlamaSDK.init(this);
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
BlitzLlamaSDK.init(this);
}
If you are using our SDK version 1.6.0, then in the init function you have to pass the API_KEY mentioned in the manifest
Java
@Override
public void onCreate() {
super.onCreate();
BlitzLlamaSDK.init(this, API_KEY);
}
It is mandatory to create users using unique user_ids. Not only does it provide a consistent experience across platforms, but also prevents users from being surveyed multiple times.
Create a user with a unique user_id to prevent any inconsistencies.
Call the logout function or clear storage, if you are switching between projects in the same device.
Java
Kotlin
BlitzLlamaSDK.getSdkManager(this).createUser("user_id");
BlitzLlamaSDK.getSdkManager(this).createUser("user_id")
In case you are facing an issue with showing the survey on the Home screen (first landing Activity), please pass a callback function as the second argument to createUser function.
import com.blitzllama.androidSDK.SdkInitialisationSuccessCallback
..
..
val clbk = object : SdkInitialisationSuccessCallback{
override fun onSuccess() {
BlitzLlamaSDK.getSdkManager(this@HomeActivity).triggerEvent("MainActivity")
}
override fun onFailure() {
BlitzLlamaSDK.getSdkManager(this@HomeActivity).triggerEvent("MainActivity")
}
}
BlitzLlamaSDK.getSdkManager(this).createUser("user_id", clbk);
Attributes are additional data points about users, that are used for creating targeted user cohorts on the Blitzllama dashboard. Attributes are optional and not required to launch a micro-survey.
Allowed data_type values are "string", "number", "date", "boolean".
Java
Kotlin
BlitzLlamaSDK.getSdkManager(this).setUserAttribute("attribute_name","attribute_value", "data_type");
BlitzLlamaSDK.getSdkManager(this).setUserAttribute("attribute_name","attribute_value", "data_type")
You can provide Blitzllama with the user's email address. Email address is not a mandatory for Android micro-surveys.
Java
Kotlin
BlitzLlamaSDK.getSdkManager(this).setUserEmail("user_email_address");
BlitzLlamaSDK.getSdkManager(this).setUserEmail("user_email_address")
You can also provide Blitzllama with the user's name. It can be used to make the questions more personalised. User name is, again, not mandatory to launch surveys.
Java
Kotlin
BlitzLlamaSDK.getSdkManager(this).setUserName("user_name");
BlitzLlamaSDK.getSdkManager(this).setUserName("user_name")
You can provide Blitzllama with the language you wish to survey your user. It is not mandatory to launch surveys.
Java
Kotlin
BlitzLlamaSDK.getSdkManager(this).setSurveyLanguage("language_code");
BlitzLlamaSDK.getSdkManager(this).setSurveyLanguage("language_code")
Triggers, when initiated, display the micro-survey to the users. You can add triggers to all components - button press, screen open or screen close - that are critical in a user's journey.
There are two methods to create a trigger:
Method 1: Add new trigger_name in your app and it will automatically be created if it doesn't exist and then be available for selection in the dashboard.
Method 2: To add a trigger into your app, first create a trigger on the Blitzllama dashboard with a trigger_name, then use the same trigger_name in the following function.
Make sure to create a user before triggering a survey.
Java
Kotlin
BlitzLlamaSDK.getSdkManager(this).triggerEvent("trigger_name")
BlitzLlamaSDK.getSdkManager(this).triggerEvent("trigger_name")
You can also attach properties to each event. Event schemas can be changed on the dashboard. This is an optional feature.
// Some code
HashMap<String, Object> eventProperties = new HashMap<String, Object>();
mapValues.put("event Key", "event Value");
mapValues.put("event Key1", "event Value1");
BlitzLlamaSDK.getSdkManager(this).triggerEvent("trigger_name",eventProperties)
You can use these properties to more filter users in the survey, as shown in the below screenshot.

You can also use backend events to launch in-app surveys. Check out https://documentation.blitzllama.com/connections/backend-trigger for more details.
Blitzllama provides a survey complete event that you might find useful to trigger certain actions in your application.
import com.blitzllama.androidSDK.common.OnSurveyCompletionListener;
..
..
HashMap<String, Object> eventProperties = new HashMap<String, Object>();
mapValues.put("event Key", "event Value");
OnSurveyCompletionListener listener = result -> {
Log.d("result",result.toString());
};
BlitzLlamaSDK.getSdkManager(this).triggerEvent("trigger_name",eventProperties,listener)
// Some code
{
"group_id": "g-d8ee8...",
"survey_id": "s-d8ee8...",
"event_name": "trigger name"
}
Every release we extensively test our SDK in multiple sample apps across devices and Android versions for crashes and performance issues. The performance impact is negligible and below are the stats for the latest SDK version.
- Load times: All calls are async and hence does not impact app or screen load times.
- App size: Blitzllama SDK AAR size is 150kb and it's size impact on an Android app is about 200kb.
- CPU usage: A negligible increase of 1-5% CPU usage only when the micro survey is on-screen.
Version 1.7.4 - 12 August, 2023
- Frontend callback event on survey completion
Version 1.6.11 - 20 February, 2023
- Added support for right to left languages like Arabic
Version 1.6.9 - 2 February, 2023
- Add Question Image
Version 1.6.8 - 7 September, 2022
- API and cache optimisations
- This version fixes minor bugs and issues with no code triggers when used in fragments.
- Enable/Disable logs from the SDK by passing a boolean at the initialization time.
- Emoji Feedback
- Recommend use of AppCompatActivity while using the SDK, otherwise the surveys won't show up.
- Use of No code triggers - with fragments
- Star Feedback
- UI improvements
- Option added for making question mandatory
- No code triggers with Activity
- API key name changed - blitz_api_key (in manifest)
- Application class extension removed. i.e. no need to extend the SDK's application class.
- Pro guard rules added
- Set default language setting added
Last modified 20d ago