how to get the IP of the wifi hotspot in Android?

后端 未结 7 1236
半阙折子戏
半阙折子戏 2021-02-02 14:11

As the title says... I\'m trying to be able to get the IP of the wifi iface when it is configured as hotspot. Ideally, I would like to find something that works for all the phon

7条回答
  •  借酒劲吻你
    2021-02-02 15:04

    Here is a possible solution that utilizes WiFiManager ConnectionInfo to find corresponding NetworkInterface.

    If you just need the IP then you can use:

    WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    int ipAddress = wifiInfo.getIpAddress();
    

提交回复
热议问题