Android: Setup outside Application class

📘

This guide is focused on Android (Kotlin/Java).

Sometimes it is not possible to initialize SDK at the start of the application. A typical example is when you need to fetch your api key so you don't have your api key at the application start.

If this is the case you will need to provide the SDK setup with an actual Activity reference so the SDK can “catch up” with the application’s lifecycle.

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle) {
        super.onCreate()

        val options = Smartlook.SetupOptionsBuilder(YOUR_API_KEY)
                .setActivity(this)
                .build()

        Smartlook.setupAndStartRecording(options)
    }
}
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate();

        Smartlook.SetupOptionsBuilder builder = new Smartlook.SetupOptionsBuilder(YOUR_API_KEY)
                .setActivity(this);

        Smartlook.setupAndStartRecording(builder.build());
    }
}