Android Ecosystem quick start
Target Platforms
This quick start guide shows you how to get Heap setup in an Android application that runs on Android TV, Android Wear, and Android Auto/Automotive.
After completing the setup process, you will be able to:
- Take full advantage of the Heap API to track custom events and manage user identity.
- Automatically capture changes to the installed app version when recording starts.
If you're using Heap Classic and thinking of switching to our latest offerings, check out the full breakdown of the differences between our SDKs here.
Before you begin
The below guide assumes a standard
<project>/<app>
configuration and use of the most up-to-date Gradle syntax. If you're using the legacy Gradle syntax in your project, visit our custom configuration guide here.
All Heap Android SDKs are distributed via Maven Central. To make sure your application can access the required artifacts, you will need to add Maven Central as a dependency repository.
In your project-level settings.gradle
file, add a reference to Maven Central:
dependencyResolutionManagement {
repositories {
...
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
...
mavenCentral()
}
}
Add the Heap SDK to your application
- In your app-level
build.gradle
file, add the dependency for the Heap Android Core SDK.
dependencies {
implementation 'io.heap.core:heap-android-core:0.7.+'
}
dependencies {
implementation("io.heap.core:heap-android-core:0.7.+")
}
-
Once the dependency has been added, sync Gradle and rebuild your application.
-
To enable Heap, call
startRecording
. This can go anywhere in your app, but we recommend doing this in theonCreate
method of your appāsApplication
object to make sure tracking starts, no matter how your app is opened.
import io.heap.core.Heap
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Replace YOUR_ENVIRONMENT_ID with the ID of the Heap environment you wish to send data to.
Heap.startRecording(this, "YOUR_ENVIRONMENT_ID")
}
}
import io.heap.core.Heap;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Replace YOUR_ENVIRONMENT_ID with the ID of the Heap environment you wish to send data to.
Heap.startRecording(this, "YOUR_ENVIRONMENT_ID");
}
}
Once recording has started, youāre able to take full advantage of Heapās API to identify users, track custom events, and more. Heap will also automatically start tracking app version changes without any additional code.
What next?
Start capturing events! Learn all about Heapās custom event tracking APIs here.
To find out how to take full advantage of the Heap API to enhance your data capture, check out our mobile tracking guides here.
Updated about 2 months ago