Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1004197 // androidGetGateway

JavaX fragment (include)

1  
//import android.net.DhcpInfo;
2  
//import android.net.wifi.WifiManager;
3  
4  
// generified (compiles everywhere)
5  
static S androidGetGateway() {
6  
  O wifii = call(androidContext_gen(), "getSystemService", "wifi");
7  
  O d = call(wifii, "getDhcpInfo");
8  
  int g = (int) get(d, "gateway");
9  
  ret g == 0 ? null : androidGetGateway_intToIP(g);
10  
}
11  
12  
static S androidGetGateway_intToIP(int addr) {
13  
  return  ((addr & 0xFF) + "." + 
14  
          ((addr >>>= 8) & 0xFF) + "." + 
15  
          ((addr >>>= 8) & 0xFF) + "." + 
16  
          ((addr >>>= 8) & 0xFF));
17  
}

Author comment

Began life as a copy of #1004196

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004197
Snippet name: androidGetGateway
Eternal ID of this version: #1004197/1
Text MD5: f9b7ec64795c00c4fb9e6a15b54bc8ca
Author: stefan
Category: javax / android
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-09 23:26:57
Source code size: 549 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 512 / 523
Referenced in: [show references]