Android SDK

Using our Android SDK makes it easy to integrate Shen.AI into a new or existing native Android app.

The best way to get started is to download and build the example app - available here on GitHub (opens in a new tab).

Installing the SDK package

Download the Shen.AI aar package (shenai_sdk.aar) and add it to your project as a dependency in build.gradle.

dependencies {
    implementation files('./path/to/your/shenai_sdk.aar')

See the Customer Portal for SDK downloads.

Needed permissions

To use Shen.AI your app needs to have certain permissions. Obviously, permission to use camera but also Internet access to check the license. It is possible to use Shen.AI without Internet connection, but first usage on the device always needs to check the license, so the permission is obligatory. Adding following lines to your AndroidManifest.xml will suffice.

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="" android:required="true" />
<uses-permission android:name="android.permission.INTERNET"/>

Preparing necessary app components

To use Shen.AI your Android app, you need to have an Android Activity, which you can use to initialize the SDK, as in the example app:

import ai.mxlabs.shenai_sdk.ShenAIAndroidSDK;
private val shenaiSDKHandler = ShenAIAndroidSDK()
shenaiSDKHandler.initialize(this, "YOUR_API_KEY", ...);

The attached activity is used for camera initialization and to access app files.

The activity is also necessary to create the View for displaying the SDK's UI

import ai.mxlabs.shenai_sdk.ShenAIView;
ShenAIView shenaiView = new ShenAIView(this);

It is expected that the Activity passed to the ShenAIView is an instance of LifecycleOwner (opens in a new tab) - in such a case, the view will properly react to app lifecycle events, releasing resources when the activity is paused.

If for some reason your Activity is not a LifecycleOwner, you can use the ShenAIView.activityPaused() and ShenAIView.activityResumed() methods to manually notify the view about lifecycle events.

Further steps

Please see permissions, initialization, configuration and video measurement for further steps.