Wednesday, November 9, 2011

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" />

No comments:

Post a Comment

Androidians