Get android Ethernet MAC Address (not wifi interface)

后端 未结 8 1755
南旧
南旧 2021-02-05 12:12

I\'m using Android with Api level 8 and I want to get the Address of my Ethernet interface (eth0).

On API level 8, the NetworkInterface class don\'t have the function ge

8条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-05 12:29

    Right now (March 2014) Google doesn't privides an API about Ethernet

    This is the rason because we don't have a way to get the ethernet mac like in wifi case.

    private String getWifiMACAddress(Context ctx) {
        WifiManager wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
        WifiInfo info = wifiManager.getConnectionInfo();
       return info.getMacAddress();
    }
    

    One alternative is reading the eth0 file. Please let me know if anyone knows otherwise!

提交回复
热议问题