Libraryless. Click here for Pure Java version (128L/2K/4K).
!752 import android.net.*; import android.net.wifi.WifiManager; p { String s_dns1 ; String s_dns2; String s_gateway; String s_ipAddress; String s_leaseDuration; String s_netmask; String s_serverAddress; DhcpInfo d; WifiManager wifii; wifii = (WifiManager) androidContext().getSystemService(Context.WIFI_SERVICE); d=wifii.getDhcpInfo(); s_dns1="DNS 1: "+intToIp(d.dns1); s_dns2="DNS 2: "+intToIp(d.dns2); s_gateway="Default Gateway: "+intToIp(d.gateway); s_ipAddress="IP Address: "+intToIp(d.ipAddress); s_leaseDuration="Lease Time: "+intToIp(d.leaseDuration); s_netmask="Subnet Mask: "+intToIp(d.netmask); s_serverAddress="Server IP: "+intToIp(d.serverAddress); S text = "Network Info\n"+s_dns1+"\n"+s_dns2+"\n"+s_gateway+"\n"+s_ipAddress+"\n"+s_leaseDuration+"\n"+s_netmask+"\n"+s_serverAddress; print(text); } static S intToIp(int addr) { return ((addr & 0xFF) + "." + ((addr >>>= 8) & 0xFF) + "." + ((addr >>>= 8) & 0xFF) + "." + ((addr >>>= 8) & 0xFF)); }
See http://stackoverflow.com/questions/5387036/programmatically-getting-the-gateway-and-subnet-mask-details
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, crvwmplrxojx, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, ybmhnqzijvxm
ID | Author/Program | Comment | Date |
---|---|---|---|
1286 | stefan | On the tablet, anyway. Phone gives all 0 | 2016-08-09 22:48:55 |
1285 | stefan | Works! | 2016-08-09 22:47:51 |
Snippet ID: | #1004196 |
Snippet name: | Detect Gateway On Android [Spike] |
Eternal ID of this version: | #1004196/1 |
Text MD5: | 21e68e7dda12c14ef987345cecad7a5e |
Transpilation MD5: | 401cf46753c52c60daefefd9a6cacfd2 |
Author: | stefan |
Category: | javax / android |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-09 22:45:11 |
Source code size: | 1124 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 775 / 855 |
Referenced in: | [show references] |