Reputation: 147
How to get the mac address in the absence of the wifi!! and am using the following code to get the mac address in the presence of the wifi `public static String getMACaddress(Context ctx) {
WifiManager wifiManager = (WifiManager)ctx.getSystemService(Context.WIFI_SERVICE);
if (wifiManager.isWifiEnabled())
{
WifiInfo wInfo = wifiManager.getConnectionInfo();
String macAddress = wInfo.getMacAddress();
}
`
in the else part i want to get the mac address in the normal way i mean without the internet connection.
Upvotes: 0
Views: 1640
Reputation: 1477
See the below post.. In this without using of wifi connection getting mac address.may it will help you.
// AndroidManifest.xml permissions
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
// test functions
Utils.getMACAddress("wlan0");
Utils.getMACAddress("eth0");
Utils.getIPAddress(true); // IPv4
Utils.getIPAddress(false); // IPv6
How to get IP address of the device from code?
Upvotes: 1