174 lines
5.1 KiB
Markdown
174 lines
5.1 KiB
Markdown
# 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
|
|
|
|
Add the library to your Android project:
|
|
|
|
### Gradle (Kotlin DSL)
|
|
```kotlin
|
|
dependencies {
|
|
implementation("dev.oxmc:androiddeviceinfo:1.0.0")
|
|
}
|
|
```
|
|
|
|
### Gradle (Groovy)
|
|
```groovy
|
|
dependencies {
|
|
implementation 'dev.oxmc:androiddeviceinfo:1.0.0'
|
|
}
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
### Basic Device Information
|
|
|
|
```kotlin
|
|
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)
|
|
|
|
```kotlin
|
|
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
|
|
|
|
```kotlin
|
|
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 integrates with an online API to provide:
|
|
|
|
- Device images
|
|
- Additional device specifications
|
|
- Device reporting capabilities
|
|
- Updated device database
|
|
|
|
API endpoints are configurable through `DeviceInfo` object properties.
|
|
|
|
## 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.
|