Open In App

How to Get the MAC of an Android Device Programmatically?

Last Updated : 15 Mar, 2024
Like Article

MAC stands for Media Access Control. The MAC address is also known as the Equipment Id Number. This MAC Address is provided by the Network Interface Card. In this article, we will see step by step from creating a new empty project to How to make an android app to display MAC Address using Java.

Note: All the hardware access has been removed after Android 11, so if you want to follow these steps then you have to choose the lower version of Android 11.

Step by Step Implementation

Step 1: Open an ‘Android Studio’ and click on New Project.


Step 2: Select Empty Activity.


Step 3: Select Java as the language for your Android app and give it any name you want.


Step 4: Add the following Permissions in the AndroidManifest.xml file.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name = "android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS" />

AndroidManifest.xml file will look like this

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""

    <!-- Permissions -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name = "android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS" />
    <!-- Permissions -->    
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />


Step 5: Make a simple design to show MAC Address.

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.

<?xml version="1.0" encoding="utf-8"?>

        android:text="You Device's MAC Address "

        android:text="MAC ID"


The above code makes the UI like the below.

Step 6: Now we are in the final phase of the project, Import WifiInfo and WifiManager classes using the below lines of code in  


Step 7: Go to the file and refer to the following code. Below is the code for the file.

import android.annotation.SuppressLint;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;


public class MainActivity extends AppCompatActivity {

    TextView macIdTV;

    protected void onCreate(Bundle savedInstanceState) {

        macIdTV = findViewById(;

        WifiManager wifiMgr = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
        WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
        final String MAC_ADDRESS = wifiInfo.getMacAddress();


Now all are set, just run your app and you will be able to see the MAC address of your Android device. Hooray!


Similar Reads

How to Get Current Default Language of Android Device Programmatically?
Smartphones seem to be predicting and showing us results from what we think in our minds. If you think of traveling, you shall soon expect something related to it in your device's feed. This is the next level of technology, where data helps in developing businesses. The software collects personal data like recent searches, device location, etc., to
2 min read
How to Get the Device's IMEI and ESN Programmatically in Android?
Many times while building Android Applications we require a unique identifier to identify the specific mobile users. For identifying that user we use a unique address or identity. For generating that unique identity we can use the android device id. In this article, we will take a look at How to get Device IMEI and ESN Programmatically in Android.
4 min read
How to Get the Device's IMEI/ESN Programmatically in Android using Jetpack Compose?
Android applications many times require the unique identity of the user while developing applications. This unique identity is used to identify the user of the application. Many android apps use the IMEI number as the unique identity of each user. In this article, we will take a look at How to get Device IMEI and ESN Programmatically in android usi
4 min read
How to Get the MAC of an Android Device using NetworkInterface Class?
The MAC (Media Access Control) address in Android is a unique identifier assigned to the Wi-Fi module of the device. It is used to identify devices on a network and helps in network communication and security. The general method for getting the MAC address of the android device is using the Wifi Manager class in android studio. Getting mac using wi
3 min read
How to Find the Screen Resolution of a Device Programmatically in Android?
Screen Resolution refers to the number of pixels on display. A higher resolution means more pixels and more pixels provide the ability to display more visual information. This entity is widely used in applications related to the broadcasting of real-time visuals such as live video, gaming, etc for optimization and frame conversions. The same inform
3 min read
How to Display the List of Sensors Present in an Android Device Programmatically?
All Android devices produced worldwide come with built-in sensors that measure motion, orientation, and various environmental conditions. These sensors generally facilitate Android architecture by providing the data from the sensor for various applications. For example, a temperature sensor provides the device's temperature, information from which
3 min read
How to Vibrate a Device Programmatically in Android?
Hepatic feedback are also considered when it comes to user experience. So in this discussion, it's been discussed various types of haptics or the types of vibration of the device. For example, click haptics or long-press button haptics. There five different types of vibration modes in haptic feedback discussed are: Default vibration of the deviceCl
7 min read
How to Fetch Device ID in Android Programmatically?
The android Device ID is a unique code, string combinations of alphabets and numbers, given to every manufactured android device. This code is used to identify and track each android device present in the world. In Android, the Device ID is typically related to the Google Play Services and is most commonly used in ad personalization. These IDs are
3 min read
Android Device Manager - Find My Device
Android Device Manager (ADM), nowadays known as Find My Device, is a very useful feature offered by Google to help Android users locate, secure, and manage their smartphones and tablets in case they are lost or stolen. This powerful tool offers a range of functionalities that provide peace of mind and ensure the safety of your Android devices. In t
8 min read
How to Get RAM Memory in Android Programmatically?
RAM (Random Access Memory) of a device is a system that is used to store data or information for immediate use by any application that runs on the device. Every electronic device that runs a program as a part of its application has some amount of RAM associated with it. Mobile devices nowadays come with a RAM of 4 to 16 GB depending on the model. T
3 min read