Model Number and IMEI In Android

Model Number and IMEI In Android Kotlin

In this tutorial we will design a very simple application to fetch some basic details of any android phone including Model number and IMEI In Android Studio using Kotlin language. We are going to fetch the following details.

1- Current time Of The Android Device.

2- Current Date Of The Device.

3- If Wifi is connected OR Not.

4- Phone Model.

5- SDK Version.

6- Device Name.

7-  Product

8- IMEI Number.

So lets start designing our application Model number and IMEI In Android Studio.

Model Number and IMEI In Android Kotlin:

1- Start a new Android Studio Project and name it as “PhoneDetails” or you can name it whatever you want. Select API level 19 and select the default language as Kotlin.

2- First of all go to your AndroidManifest.xml file and add these two permissions.

 

3- Go to activity_main.xml and change the default Constraint Layout to Relative Layout. Set the gravity of your Relative layout as ” center “.

4- In our activity_main.xml file we need a couple of TextViews. We are fetching some 8 different types of details so we need 16 TextViews. 8 TextViews will display the name of the details like ( Date, Time, Wifi Status, Phone Model, SDK, Device, Product and IMEI) and the other 8 TextViews will display the actual values.

5- After designing the TextViews and adding required attributes our final activity_main file will look exactly like this.

 

MainActivity.kt Code

6- Now we will start our Kotlin code. Come to MainActivity.kt file and here for each detail we will create a separate function.

7- Below our onCreate Method we will define our first method to fetch the current Date of the Android Device. After fetching it we will display it in our TextView. Our displayDate() function will be like this. On clicking the date it will show a Toast message too.

 

8- We will add a separate function to display the current time of the Device in the TextView. Our displayTime() function will look like this.

 

9- To check if the wifi is connected or not we will use this method. If the Wifi is connected it will show “Connected” and if it’s not connected it will show “Disconnected”. Our function will look like this.

 

10- Function to fetch the Model of the Device.

 

11- This function will fetch the current SDK version.

 

12- To fetch the Device name.

 

13- To find the Build Product of the Android Device we will use this function.

 

14- For finding the IMEI number of the device we use a try and catch block. If successful the try block will fetch the IMEI number of the device if it didn’t it would return an exception. It asks for the user permission first. This is how our function will look like.

 

15- Now, we have 8 different functions for 8 different details. We make another function with name allFunctions() and call all our 8 functions in this function, just like this.

 

onCreate() Function

16- Now finally, we just have to call one function in our onCreate function. Like this.

 

17- Here we are done, our complete final MainActivity.kt file is this.

OUTPUT

Model Number and IMEI In Android
Model Number and IMEI In Android
Model Number and IMEI In Android
Model Number and IMEI In Android

 

People Also Read:

 

Enable or Disable Wifi In Android Programmatically In Kotlin

Kotlin Speech To Text Example

Kotlin Text To Speech Working Example 

How To Check Internet Connection in Android Programmatically

Leave a Comment

Your email address will not be published. Required fields are marked *