Android SDK for collecting and reporting device data to MaxMind.
- Android API 29+ (Android 10+)
- Kotlin 1.9.22+
- AndroidX libraries
Add the dependency to your app's build.gradle.kts:
dependencies {
implementation("com.maxmind.device:device-sdk:0.1.0")
}dependencies {
implementation 'com.maxmind.device:device-sdk:0.1.0'
}Initialize the SDK in your Application class or main activity:
import com.maxmind.device.DeviceTracker
import com.maxmind.device.config.SdkConfig
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val config = SdkConfig.Builder(123456) // Your MaxMind account ID
.enableLogging(BuildConfig.DEBUG)
.build()
DeviceTracker.initialize(this, config)
}
}lifecycleScope.launch {
DeviceTracker.getInstance().collectAndSend()
.onSuccess {
Log.d("SDK", "Data sent successfully")
}
.onFailure { error ->
Log.e("SDK", "Failed to send data", error)
}
}DeviceTracker.getInstance().collectAndSend { result ->
result.onSuccess {
Log.d("SDK", "Data sent successfully")
}.onFailure { error ->
Log.e("SDK", "Failed to send data", error)
}
}DeviceTracker.getInstance().collectAndSend(result -> {
if (result.isSuccess()) {
Log.d("SDK", "Data sent successfully");
} else {
Throwable error = result.exceptionOrNull();
Log.e("SDK", "Failed to send data", error);
}
});Collect device data without sending:
val deviceData = DeviceTracker.getInstance().collectDeviceData()
println("Device: ${deviceData.build.manufacturer} ${deviceData.build.model}")val config = SdkConfig.Builder(123456) // Your MaxMind account ID
.serverUrl("https://custom-server.com/api") // Optional: Custom server URL
.enableLogging(true) // Optional: Enable debug logging
.collectionInterval(60_000) // Optional: Auto-collect every 60 seconds
.build()| Builder Method | Type | Default | Description |
|---|---|---|---|
Builder(accountID) |
Int | required | Your MaxMind account ID |
.serverUrl(url) |
String | Default servers | Custom server URL |
.enableLogging(enabled) |
Boolean | false |
Enable debug logging |
.collectionInterval(ms) |
Long | 0 |
Auto-collection interval in milliseconds (0 = disabled) |
The SDK requires the following permissions (automatically included):
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />The SDK includes consumer ProGuard rules. No additional configuration is needed.
See the sample module for a complete working example demonstrating:
- SDK initialization
- Device data collection
- Data transmission
- Error handling
To run the sample app:
./gradlew :sample:installDebug./gradlew :device-sdk:assemble./gradlew :device-sdk:test./gradlew :device-sdk:dokkaHtmlDocumentation will be generated in device-sdk/build/dokka/.
- Fork the repository
- Set up your development environment (see SETUP.md)
- Create a feature branch
- Make your changes
- Run tests and code quality checks
- Submit a pull request
This software is Copyright (c) 2025 by MaxMind, Inc.
This is free software, licensed under the Apache License, Version 2.0 or the MIT License, at your option. Copyright 2025 MaxMind, Inc.
For support, please visit maxmind.com/en/company/contact-us.
If you find a bug or have a feature request, please open an issue on GitHub.