Important: As of August 13, 2024, this page will no longer be actively maintained. Please refer to the current version of this content here.
Our Android library is available on Maven Central as an AAR artifact. If your project uses Gradle, you can integrate by adding the following dependency:
repositories {
mavenCentral()
}
dependencies {
compile 'com.indicative.client.android:Indicative-Android:1.0.1'
}
Otherwise, download the client and add the Indicative.java file (located in /src/com/indicative/client/java/android/) to your project.
To start recording events, you’ll first have to create an instance of our Analytics object and initialize it with your API key. You can do this by calling our launch() method in the onCreate() method of your main Application class, like so:
Indicative.launch(getApplicationContext(), "Your-API-key-goes-here");
To record an event, first create a Map of your property names and values:
Map<String, String> properties = new HashMap<String, String>();
properties.put("Age", "23");
properties.put("Gender", "Female");
Next, simply call our recordEvent() method, passing in the event name, a unique user identifier, and the property map you just created:
Indicative.recordEvent("Registration", "user47", properties);
This method creates a JSON representation of your event and adds it to a queue. Every 60 seconds, the events in that queue will be sent to our Rest API endpoint via HTTP POST requests. If debug mode is enabled via the debug booleanin Indicative.java, the status code and body of our response will be outputted to your device’s logs.