Skip to main content

Initialization

After creating your project and adding your app in the Administration portal, you will obtain a configuration file that needs to be added to the app project. Each configuration file can only be used for the app it was generated for, specifically to the application id.

The configuration file must be copied under the assets/ directory, or in an arbitrary subdirectory of assets/.

You will need to define a subclass of the android.app.Application class. In your application subclass, inside the onCreate() method, initialize AutomatID:

class App: Application() {
override fun onCreate() {
super.onCreate()
val configFile = "my/directory/automatid-myapp-android.json" // the path where you placed the configuration file, relative to the assets/ directory
val configuration = AutomatIdConfiguration.Builder().build() // see 'Customization' for configuration options
val initResult = AutomatIdManager.init(this, configFile, configuration)
if (initResult is AutomatIdInitResult.Error) {
Log.e("AutomatId", "AutomatId init error: $initResult")
}
}
}

Remember to declare the App class in the AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:name="com.myapp.App">
</application>
</manifest>

Please that the init() method must only be called once during the application initialization. Do not call it multiple times, for example on each activity or fragment initialization.