Getting Started with the Android SDK

The Moonsense Android SDK is designed to make integrating Moonsense into your Android application or SDK as easy as possible.

The sections below will walk you through configuring access to download and integrate the SDK, initializing the SDK, and recording a session.

Integration

All that is needed to download the SDK is a repo access token. This token should have been provided to you. In case you do not have one contact support@moonsense.io. Once you have the repo access token, you can add it to your maven config in gradle like so:

repositories { maven { val repoAccessToken = "ADD_TOKEN_HERE" url = uri("https://dl.moonsense.io/$repoAccessToken/sdk/maven") } }

With the repository set up, you can add the SDK dependency to your app/module using the following line:

implementation("io.moonsense:android-sdk:<latest_version>")

Version History

Details about the current and past releases can be found in the Releases section.

Usage

The SDK needs to be initialized before use. Use the initialize() method in either the Application.onCreate() or Activity.onCreate() to prepare the SDK for recording. SDK/Library developers can add initialize() to their SDK initialization routine. The initialize() call expects a publicToken generated using the Moonsense Console. In order to obtain a token you need to:

  • Have a valid Moonsense account.
  • Set up a project for the SDK to use. The default can be used in case you do not want to create one.
  • Configure an application for the SDK to record to.
  • Once the app is set up, use the Create token button to obtain the secret and public token to use. The SDK expects the public token as a part of the initialize() call. You can hold on to the secret token to read from the Moonsense Cloud later.

Once initialized you can use the startSession() and stopAllSessions() to start and stop recording sessions respectively. If you need a finer control over stopping individual sessions, the startSession() call returns a Session object that includes a stopSession() method.

Additionally, a MoonsenseCallback can be registered to provide the caller with events from the SDK.

android.sdk-docs.moonsense.io contains a more detailed reference for the SDK.

Sample Apps

This public repo moonsense-android-sdk includes two sample apps:

  • sample-app - This sample app demonstrates the use of the Moonsense Android SDK within an application context. The example in this case is quite simple and minimal and can serve as a good starting point for developers looking for a quick integration.
  • sample-payment-app - This sample app demonstrates the library usage of the Moonsense Android SDK. Note that the sample-payment-app does not directly depend on the Moonsense Android SDK. Instead it includes a dependency to the sample-payment-sdk which then packages the Moonsense Android SDK. The app developer here does not have any visibility into the Moonsense Android SDK as they only interface with the sample-payment-sdk. The example is useful for SDK/library developers looking to integrate the Moonsense Android SDK.