Android SDK
The AttributeHQ Android SDK provides install attribution, event tracking, and Google Play Install Referrer support for native Android apps.
Features
- Kotlin with minSdkVersion 21 (Android 5.0+)
- Singleton pattern —
AttributeHQobject - Install Referrer — Deterministic attribution via Google Play Install Referrer API
- GAID — Google Advertising ID collection
- Background thread — All network and I/O on dedicated
ScheduledExecutorService - Lifecycle-aware —
ProcessLifecycleOwnerfor background/foreground detection - Offline queue — Events persist in SharedPreferences
- Zero JSON dependencies — Uses built-in
org.json - Zero HTTP dependencies — Uses
HttpURLConnection
Architecture
- Device ID priority: GAID (if not opted out) → SharedPreferences UUID → new UUID
- Thread safety: Single-thread
ScheduledExecutorService(attributehq-sdk) - Storage: SharedPreferences for events, settings, and device ID
Quick Example
import com.attributehq.sdk.AttributeHQ
import com.attributehq.sdk.AttributeHQConfiguration
// Initialize in Application.onCreate()
val config = AttributeHQConfiguration(
apiKey = "ak_your_api_key",
appId = "your-app-uuid"
)
AttributeHQ.initialize(this, config)
// Track events
AttributeHQ.track("purchase", mapOf("amount" to 1500, "currency" to "NGN"))
// Get attribution
val attribution = AttributeHQ.getAttribution()
attribution?.let {
println("Source: ${it.mediaSource ?: "organic"}")
}Next Steps
- Installation — Gradle setup and configuration
- Event Tracking — Events, revenue, identification
- Install Referrer & GAID — Deterministic attribution on Android
- API Reference — Full method and type reference