- WifiManager wm = (WifiManager)getSystemService(WIFI_SERVICE);
- DhcpInfo di = wm.getDhcpInfo();
- long getewayIpL=di.gateway;
- String getwayIpS=long2ip(getewayIpL);//网关地址
- long netmaskIpL=di.netmask;
- String netmaskIpS=long2ip(netmaskIpL);//子网掩码地址
- String long2ip(long ip){
- StringBuffer sb=new StringBuffer();
- sb.append(String.valueOf((int)(ip&0xff)));
- sb.append('.');
- sb.append(String.valueOf((int)((ip>>8)&0xff)));
- sb.append('.');
- sb.append(String.valueOf((int)((ip>>16)&0xff)));
- sb.append('.');
- sb.append(String.valueOf((int)((ip>>24)&0xff)));
- return sb.toString();
- }
- //注意添加权限
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
func QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits. func QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits.
评论
发表评论