Introduction
This article demonstrates how to add a device year class library using the android studio and XML code.
Android library that implements a simple algorithm that maps a device's RAM, CPU cores, and clock speed to the year where that combination of specs was considered high end. This allows a developer to easily modify application behavior based on the capabilities of the phone's hardware.
| RAM | Condition | Year Class |
| 768 | 1 core | 2009 |
| 1GB | 2+ core | 2010 |
| 1GB | <1.3GHz | 2011 |
| 1.5GB | 1.3GHz | 2012 |
| 1.5GB | <1.8GHz | 2013 |
| 2GB | 1.8GHz | 2014 |
| 3GB | 2.0GHz | 2015 |
| more | 2.2GHz | 2016 & 2017 |
Let's start,
Step 1
Create a new project in Android Studio from File >> Project and fill all the necessary details.
Next, go to Gradle Scripts >> build.gradle (Module: app).Select build.gradle, The app Gradle compile the code and build types will appear. Just replace that the following code. To make a Device year class in your layout XML and add the device year library in your project or you can also Gradle
Download the latest JARs or grab via Gradle,
Compile Code
or Maven
- compile 'com.facebook.device.yearclass:yearclass:2.0.0'
- <dependency>
- <groupId>com.facebook.device.yearclass</groupId>
- <artifactId>yearclass</artifactId>
- <version>2.0.0</version>
- </dependency>
Step 2
Next, go to app >> res >> layout >> activity_main.xml.

Select the activity page. The XML code will appear, Just the following code. Create the layout of the TextView and Button.




shweta ChaudharyPosted Feb 7, 2018, 5:06 AM
You article is very useful. i am working on it.
Manish PatelPosted Jan 3, 2018, 7:43 AM
Nice article........
Sagar Pandurang KapPosted Jan 2, 2018, 11:58 PM
Nice article.......