A lightweight Kotlin library for collecting essential Android device data points required for maintaining device graphs and processing server-to-server events with Singular's API.
TL;DR:
- Collect device identifiers and system information using two main classes:
DeviceInfoandDeviceIdentifiers - Implements singleton pattern for consistent data access across your app
- Supports asynchronous operations through Kotlin Coroutines
- Provides comprehensive device data points required for Singular's REST API
Handles collection of device and system-level information:
val deviceInfo = DeviceInfo.getInstance(context)
val systemInfo = deviceInfo.getAllDeviceInfo()Available Data Points:
appVersion: Application version namepackageName: Application package identifierosVersion: Android OS versionlocale: Device locale settingsdeviceModel: Physical device modeldeviceMake: Device manufacturerbuildVersion: System build information
Manages device identification and tracking-related data:
val deviceIdentifiers = DeviceIdentifiers.getInstance(context)
lifecycleScope.launch {
val identifiers = deviceIdentifiers.getAllIdentifiers()
}Available Identifiers:
androidId: Android device identifiergaid: Google Advertising ID (requires async call)appSetId: App Set ID for user trackingadTrackingStatus: Current ad tracking authorization state
1. Initialize Components
val deviceInfo = DeviceInfo.getInstance(context)
val deviceIdentifiers = DeviceIdentifiers.getInstance(context)2. Collect All Data Points
lifecycleScope.launch {
val deviceData = deviceInfo.getAllDeviceInfo()
val identifiers = deviceIdentifiers.getAllIdentifiers()
// Combine data for server upload
val serverData = deviceData + identifiers
}Store collected data points in your device graph with these key considerations:
- Map multiple identifiers to a single user profile
- Update data points periodically to maintain accuracy
- Handle missing or null values gracefully
When sending events to Singular's REST API:
- Retrieve stored device information from your device graph
- Include relevant device data in the API payload
- Ensure consistent identifier usage across events
Android Environment:
- Minimum API Level: 21+
- Kotlin Version: 1.5+
- Android Studio: Arctic Fox or newer
Dependencies:
- Google Play Services Ads
- Google Play Services AppSet
- AndroidX Core KTX
- Kotlin Coroutines
- Cache device information to minimize API calls
- Implement proper error handling for missing identifiers
- Monitor ad tracking status changes
- Update device information periodically
- Use coroutines for asynchronous operations
- Implement proper error handling for all data collection methods
Debug collected data using built-in logging methods:
lifecycleScope.launch {
deviceInfo.printDeviceInfo()
deviceIdentifiers.printIdentifiers()
}The app provides two ways to verify collected data:
- Logcat output through printDeviceInfo()
- Visual representation in the DeviceInfo Fragment
| About the App | DeviceInfo Dictionary |
|---|---|
![]() |
![]() |

