Way to get WiFi address in Android Phones

We will get the WiFi Mac address only if the WiFi is enabled in the device. The code snippet for getting the WiFi address is

WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
String WifiMacAddress = info.getMacAddress();

The permission that we need to put in manifest file is,

<uses-permsission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permsission android:name="android.permission.CHANGE_WIFI_STATE" />


Popular posts from this blog

Open Gallery and get the selected image in appplication

Dismiss or Cancel dialog by swipe gesture

AlarmManager and Notification in Android