How to Get the Device Information in Android?
In the present world, sometimes we want to access the device information of the user to expand our business e.g. An e-commerce company may want to access the mobile’s brand of the user to provide (more specifically, to target the user for high/low price’s items) recommendation. We can find the device (hardware and software) information using Build Package in Android.
Step by Step Implementation
To get the device information follow these steps. We are going to implement it using the Kotlin language.
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Kotlin as the programming language.
Step 2: Working with the activity_main.xml file
Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file.
Step 3: Working with the MainActivity.java file
Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.