Andorid 手机WIFI连接的Mac地址和IP地址

public static String getInfo()
    {
       WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
       WifiInfo info = wifi.getConnectionInfo();
 
       String maxText = info.getMacAddress();
       String ipText = intToIp(info.getIpAddress());
       String status = "";
       if (wifi.getWifiState() == WifiManager.WIFI_STATE_ENABLED)
       {
           status = "WIFI_STATE_ENABLED";
       }
       String ssid = info.getSSID();
       int networkID = info.getNetworkId();
       int speed = info.getLinkSpeed();
       return "mac:" + maxText + "\n\r"
              + "ip:" + ipText + "\n\r"
              + "wifi status :" + status + "\n\r"
              + "ssid :" + ssid + "\n\r"
              + "net work id :" + networkID + "\n\r"
              + "connection speed:" + speed + "\n\r"
              ;
    }

private String intToIp(int ip)

{

return (ip & 0xFF) + "." + ((ip >> 8) & 0xFF) + "." + ((ip >> 16) & 0xFF) + "."

+ ((ip >> 24) & 0xFF);

}

结伴旅游,免费的交友网站:www.jieberu.com

推推族,可以免费得门票,游景区哦:www.tuituizu.com

上一篇:7.5---两个正方形分成对半的直线(CC150)


下一篇:深入理解CSS计数器