0

Is there a way to get the name of the wireless hardware on the phone. For instance on the Moto Atrix it is eth0. This is different on other devices however and I need to know what its name is per device. Any way to do this?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
jjNford
  • 5,170
  • 7
  • 40
  • 64

1 Answers1

1

The method call

    NetworkInterface.getNetworkInterfaces()

will return you an Enumeration of NetworkInterface objects. Then you can compare the MAC address of the NetworkInterface (getHardwareAddress()) with the MAC address of your WifiInfo:

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

If you want to know how to compare the String with the byte array, then look here.

Community
  • 1
  • 1
Franziskus Karsunke
  • 4,948
  • 3
  • 40
  • 54
  • Yep I have this, but how can I determine that the device is for sure wireless. I understand the OS will filter out everything except the loopback and the wireless device. But is there anything that specifically tells me its wireless? – jjNford Nov 14 '11 at 13:54
  • When I do the getHadwareAddress its not returning the correct data. I have converted to a string and it give me random character ? I'm using API level 10. Any reason why? – jjNford Nov 14 '11 at 15:29