2025-08-06 17:26:20 -07:00

Android Device Info Library

An Android library that provides comprehensive device information including device names, specifications, type detection, and device images. This library helps you get detailed information about Android devices using both local databases and online APIs.

Features

  • 📱 Device Detection: Automatically detect device type (smartphone, tablet, smartwatch, TV, etc.)
  • 🔍 Device Information: Get device name, manufacturer, model, codename, and specifications
  • 🌐 Online Database: Fetch device images and additional info from online APIs
  • 💾 Local Caching: Cache device information for offline access
  • 🚀 Kotlin Coroutines: Async operations with proper coroutine support
  • 📊 Device Type Recognition: Identify emulators, physical devices, and various device categories
  • 🔧 Vendor-Specific Support: Extensible architecture for vendor-specific features

Installation

Published to Gitea Packages on git.oxmc.me, not Maven Central, so add that repository first.

Gradle (Kotlin DSL)

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        maven { url = uri("https://git.oxmc.me/api/packages/oxmc/maven") }
    }
}
// app/build.gradle.kts
dependencies {
    implementation("dev.oxmc:androiddeviceinfo:1.2.0")
}

Gradle (Groovy)

// settings.gradle
dependencyResolutionManagement {
    repositories {
        maven { url 'https://git.oxmc.me/api/packages/oxmc/maven' }
    }
}
// app/build.gradle
dependencies {
    implementation 'dev.oxmc:androiddeviceinfo:1.2.0'
}

Quick Start

Basic Device Information

import dev.oxmc.androiddeviceinfo.AndroidInfo
import dev.oxmc.androiddeviceinfo.DeviceInfo

// Get basic device info
val brand = AndroidInfo.Info.brand
val model = AndroidInfo.Info.model
val manufacturer = AndroidInfo.Info.manufacturer

// Get Android version info
val androidVersion = AndroidInfo.Version.release
val sdkVersion = AndroidInfo.Version.sdkInt

// Get device type
val deviceType = AndroidInfo.getType(context)
println("Device type: $deviceType") // e.g., SMARTPHONE, TABLET, SMARTWATCH

Complete Device Information (Async)

import dev.oxmc.androiddeviceinfo.DeviceInfo
import kotlinx.coroutines.launch

// In a coroutine scope
lifecycleScope.launch {
    val (deviceName, manufacturer, model, codename, imageUrl) = DeviceInfo.getDeviceInfo(context)
    
    println("Device: $deviceName")
    println("Manufacturer: $manufacturer") 
    println("Model: $model")
    println("Codename: $codename")
    println("Image URL: $imageUrl")
}

Device Type Detection

import dev.oxmc.androiddeviceinfo.AndroidInfo

// Check if device is an emulator
if (AndroidInfo.isEmulator) {
    println("Running on emulator")
} else {
    println("Running on physical device")
}

// Get specific device type
when (AndroidInfo.getType(context)) {
    AndroidInfo.DeviceType.SMARTPHONE -> println("This is a smartphone")
    AndroidInfo.DeviceType.TABLET -> println("This is a tablet")
    AndroidInfo.DeviceType.SMARTWATCH -> println("This is a smartwatch")
    AndroidInfo.DeviceType.SMART_TV -> println("This is a smart TV")
    AndroidInfo.DeviceType.EMULATOR -> println("This is an emulator")
    // ... other types
}

Requirements

  • Minimum SDK: API 19 (Android 4.4 KitKat)
  • Target SDK: API 36+
  • Kotlin: 1.8+
  • Permissions: No special permissions required

Architecture

The library consists of several main components:

  • AndroidInfo: Static device information and type detection
  • DeviceInfo: Async device information with online lookup
  • DeviceName: Device name resolution and caching
  • AltDeviceNames: Alternative device name mappings
  • DBHelper: Local database operations for device data

Device Types Supported

The library can detect the following device types:

  • 📱 Smartphone: Standard Android phones
  • 📟 Tablet: Tablets and large-screen devices
  • ⌚ Smartwatch: Wear OS and other watch devices
  • 📺 Smart TV: Android TV and set-top boxes
  • 🚗 Automotive: Android Auto and car infotainment systems
  • 🏠 IoT: Internet of Things devices
  • 📖 E-Reader: E-book readers
  • 🎮 Gaming: Gaming devices and consoles
  • 🥽 VR: Virtual Reality headsets
  • 📱 Foldable: Foldable phones and devices
  • 💻 Emulator: Development emulators

Online API

The library talks to a backend for device images, CMF color resolution, report ingestion, and updates to the bundled device-names database. Endpoints are configurable through DeviceInfo object properties (api_url_base, etc).

A reference implementation of that backend lives in server/ — Express + SQLite, open source, meant to be run yourself or adapted. Its search-device/v1 endpoint is deprecated in favor of v2 (exact codename/model/manufacturer match, with optional per-unit color resolution); v1 is kept only for older clients and internally shares the same lookup logic as v2 so the two behave consistently.

Caching

Device information is automatically cached locally for:

  • Improved performance
  • Offline functionality
  • Reduced network requests
  • 30-day cache duration (configurable)

License

Copyright (C) 2017 Jared Rummler
Copyright (C) 2025 oxmc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions, please create an issue on the GitHub repository.

S
Description
No description provided
Readme
2 MiB
V1.2.1
Latest
2026-09-17 04:15:24 -07:00
Languages
Kotlin 70.7%
JavaScript 24.6%
Python 4.7%