Lifecycle & Recording

SDK setup (on application start)

Smartlook SDK setup needs to be called only once during an application’s lifetime and it should be called on application startup. There is no need to stop recording explicitly on application closure, SDK will stop itself automatically.

The best place to setup the SDK is in onCreate() method of your Application class:

import android.app.Application

class MyCustomApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        Smartlook.setupAndStartRecording(API_KEY)
    }
}
import android.app.Application;

public class MyCustomApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Smartlook.setupAndStartRecording(API_KEY);
    }
}

📘

SDK can be set up later than in Application class, typically when the Application is fetching an API key, please take a look here.

The easiest way of setting up the SDK is with setupAndStartRecording() method:

Smartlook.setupAndStartRecording(apiKey: String)
Smartlook.setupAndStartRecording(@NotNull String apiKey);

It will set the SDK up and also start the recording. SDK can be setup without starting the recording using the following:

Smartlook.setup(apiKey: String)
Smartlook.setup(@NotNull String apiKey);

🚧

Smartlook SDK needs to be initialized with an API key that can be acquired in the Smartlook Dashboard.

And then the recording can be started by calling:

Smartlook.startRecording()
Smartlook.startRecording();

Setup configuration

Some recording parameters can be configured on setup:

ParameterRequiredDefault valueDescription
apiKeyyes""Unique 40-character key identifying your app (can be found in the dashboard).
fpsno2Recorded video frame rate (allowed values between 2 and 10). Note that by setting this value settings from the dashboard will be overridden!
experimentalnofalseIf set to true it enables some experimental features such as TextureView/Maps/MapBox recording, etc.
activitynonullActual activity reference is required when setting the SDK outside of the Application class.
renderingModenoRenderingMode.NATIVEDefines the way SDK is going to capture screen image data.
renderingModeOptionnonullFurther customization of the rendering mode.
eventTrackingModesnoEventTrackingMode
.FULL_TRACKING
Event tracking modes can be used to disable some automatically detected events.
useAdaptiveFrameratenotrueAdaptive frame rate is an optimization that keeps the SDK from capturing redundant screenshots when the application is idle.

Full SDK setup configuration can be done with SetupOptionsBuilder, that provides methods for setting any of the setup parameters shown above.

val options = Smartlook.SetupOptionsBuilder(apiKey: String)
        .setFps(fps: Int)
        .setExperimental(experimental: Boolean)
        .useAdaptiveFramerate(enabled: Boolean)
        .setActivity(activity: Activity)
        .setRenderingMode(renderingMode: RenderingMode)
        .setRenderingMode(renderingModeOption: RenderingModeOption)
        .setEventTrackingModes(eventTrackingModes: List<EventTrackingMode>)
        .build()

Smartlook.setupAndStartRecording(options)
Smartlook.SetupOptionsBuilder builder = new Smartlook.SetupOptionsBuilder(@NotNull String apiKey)
        .setFps(int fps)
        .setExperimental(boolean experimental)
        .useAdaptiveFramerate(boolean enabled)
        .setActivity(@NonNull Activity activity)
        .setRenderingMode(RenderingMode renderingMode)
        .setRenderingMode(RenderingModeOption renderingModeOption)
        .setEventTrackingModes(List<EventTrackingMode> eventTrackingMode);

Smartlook.setupAndStartRecording(builder.build());

Last line can be replaced with Smartlook.setup(builder.build()) so the recording can be started later.

Start and stop recording

Recording can be started or stopped at any time, the only requirement is that the SDK is set up.

Smartlook.startRecording()
Smartlook.stopRecording()
Smartlook.startRecording();
Smartlook.stopRecording();

🚧

stopRecording()

doesn't need to be called on application closure. Recording is stopped automatically.

Check if SDK is recording

Check if SDK is currently recording can be handy when using startRecording() and stopRecording() methods. Simply call:

Smartlook.isRecording()
Smartlook.isRecording();

Reset session

Current session can be ended and a new session created by calling:

Smartlook.resetSession(resetUser: Boolean)
Smartlook.resetSession(boolean resetUser);

If resetUser is set to true, SDK will create a new visitor during the reset. This is especially beneficial when a new user needs to be identified (typically after logout).

A new session can be created on SDK setup:

val options = Smartlook.SetupOptionsBuilder(API_KEY)
        .startNewSession()
        .build()

Smartlook.setupAndStartRecording(options)
Smartlook.SetupOptionsBuilder builder = new Smartlook.SetupOptionsBuilder(API_KEY)
        .startNewSession();

Smartlook.setupAndStartRecording(builder.build());

A new visitor can also be created on SDK setup:

val options = Smartlook.SetupOptionsBuilder(API_KEY)
        .startNewSessionAndUser()
        .build()

Smartlook.setupAndStartRecording(options)
Smartlook.SetupOptionsBuilder builder = new Smartlook.SetupOptionsBuilder(API_KEY)
        .startNewSessionAndUser();

Smartlook.setupAndStartRecording(builder.build());