开始 16:23:25
//ip格式
private String int2ip(int ipInt){
StringBuilder builder = new StringBuilder();
builder.append(ipInt & 0xFF).append(".");
builder.append((ipInt >>8) & 0xFF).append(".");
builder.append((ipInt >>16) & 0xFF).append(".");
builder.append((ipInt >>24) & 0xFF).append(".");
return builder.toString();
}
//获取Ip
private String getLocalIpAddress(){
WifiManager manager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiInfo info = manager.getConnectionInfo();
int i = info.getIpAddress();
return int2ip(i);
}
时间: 2024-10-17 06:39:38