Android IP address with java

后端 未结 3 2085
春和景丽
春和景丽 2021-01-07 05:38

I\'m writing an Android video game that supports multiplayer. There is a dedicated server running which the androids connect to when the multiplayer button is clicked by ope

3条回答
  •  长情又很酷
    2021-01-07 06:10

    try this

    WifiManager wim= (WifiManager) getSystemService(WIFI_SERVICE)  ;
        List l=  wim.getConfiguredNetworks(); 
        WifiConfiguration wc=l.get(0); 
    textview.append(  "\n"+ Formatter.formatIpAddress(wim.getConnectionInfo().getIpAddress()));
    

提交回复
热议问题