Adila (Advanced Device Information Library for Android) is a Java library for getting information about an Android device. It supports all Android versions (API 1+), requires no permissions, and does not depend on any third-party library.
Android provides developers with a Build
class for getting information about the current build. But it does not provide a Device
class for getting information about the device.
Adila tries to solve this by providing developers with a Device
class. This class will try to identify the current device, at runtime, and fill the class fields with the device information (e.g. name, series) from its database.
The library currently provides the following information:
- Identity (manufacturer, name, series)
Gradle:
compile 'com.karimeldeeb.adila:library:16.8.30'
compile 'com.karimeldeeb.adila:database:16.9.10'
Instead of using the whole database
artifact, you should use one that matches your application minSdkVersion
. For example, if your application minSdkVersion
is 19, you should use database-v19
artifact. This way, you will be using a smaller database that only includes devices supporting API level 19 or higher.
Note: The database is included separately in case you want to use a different one, or make your own.
To get information about the device, simply call any of Device
class methods, or access any of its fields directly. For example:
// Get the device name
String name = Device.NAME;
The database is just a Java-based (.jar) database, where each device has its own class. The classes are named using each device Build.DEVICE
and Build.MODEL
.
The devices database is included as a .csv file. This file is based on Google's list of supported devices and can be found here. The database is then converted to .java files using a Python script.
Note: The devices.csv
file includes additional information that might, or might not, be used in the future.
If you are using ProGuard with your application, you must add proguard-adila.pro file to proguardFiles
. This file will stop ProGuard from removing all classes in the database.
Example:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-adila.pro'
}
}