| 124 | } |
| 125 | |
| 126 | private static String getWifiAddress() { |
| 127 | WifiManager manager = (WifiManager) Init.context().getApplicationContext().getSystemService(Context.WIFI_SERVICE); |
| 128 | int ip = manager.getConnectionInfo().getIpAddress(); |
| 129 | return ip == 0 ? "" : String.format(Locale.getDefault(), "%d.%d.%d.%d", ip & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (ip >> 24) & 0xFF); |
| 130 | } |
| 131 | |
| 132 | private static String getHostAddress(String keyword) throws SocketException { |
| 133 | for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) { |