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

1. Integrating the SDK

We recommend using AppCompatActivity while using the SDK, otherwise the surveys won't show up.

HomeActivity extends AppCompatActivity{
}

Installation

You can install the Blitzllama SDK via maven central.

dependencies {
    implementation 'com.blitzllama:Blitzllama:1.8.0'
}

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"
  }
}

Integration

Step 1: Add the following to your Manifest class

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" />
    ...

Step 2: Create Application class

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>"

Step 3: Initialise Blitzllama SDK

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.

@Override
    public void onCreate() {
        super.onCreate();
        BlitzLlamaSDK.init(this);
        }

2. Managing Users

Create User

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.

BlitzLlamaSDK.getSdkManager(this).createUser("user_id");

Logout User

You can call this function, if you wish to stop tracking the user & their events.

BlitzLlamaSDK.logout();

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);

Update User Attributes

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".

BlitzLlamaSDK.getSdkManager(this).setUserAttribute("attribute_name","attribute_value", "data_type");

Update User Email

You can provide Blitzllama with the user's email address. Email address is not a mandatory for Android micro-surveys.

BlitzLlamaSDK.getSdkManager(this).setUserEmail("user_email_address");

Update User Name

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.

BlitzLlamaSDK.getSdkManager(this).setUserName("user_name");

Set User Language

You can provide Blitzllama with the language you wish to survey your user. It is not mandatory to launch surveys.

BlitzLlamaSDK.getSdkManager(this).setSurveyLanguage("language_code");

Language code should be in ISO 639-1 codes.

3. Adding Triggers

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.

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.

Advanced Options

Frontend Callback

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)

Sample Callback data

// Some code
{
    "group_id": "g-d8ee8...",
    "survey_id": "s-d8ee8...",
     "event_name": "trigger name"
}

Performance Impact

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.

Release Notes

New features and changes

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

Version 1.6.6 - 9 June, 2022

  • 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.

Version 1.6.3 - 7 June, 2022

  • Emoji Feedback

  • Recommend use of AppCompatActivity while using the SDK, otherwise the surveys won't show up.

  • Use of No code triggers - with fragments

Version 1.6.0 - 11 May, 2022

  • Star Feedback

  • UI improvements

  • Option added for making question mandatory

Version 1.5.0 - 8 March, 2022

  • 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.

Version 1.4.0 - 7 December, 2021

  • Pro guard rules added

  • Set default language setting added

Last updated