得到设备的ip
1.
4.
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);???
??? WifiInfo wifiInfo = wifiManager.getConnectionInfo();
??? DhcpInfo dhcpInfo = wifiManager.getDhcpInfo();
?
// [...]
?
tv = (TextView) findViewById(R.id.id_wlan_ip_address);
tv.setText(intToIp(dhcpInfo.ipAddress));
?
// [...]
?
??? /**
???? * http://teneo.wordpress.com/2008/12/23/java-ip-address-to-integer-and-back/
???? */
??? private String intToIp(int i) {
??? return ( i??????? & 0xFF) + "." +
??? ((i >>? 8 ) & 0xFF) + "." +
??? ((i >> 16 ) & 0xFF) + "." +
??????? ((i >> 24 ) & 0xFF)
??????? ;
??? }