androidnetwork-programmingandroid-wifiwirelessandroid-wireless

How to list all connected nodes in android application (using WIFI)?


It is possible to list all connected nodes in my android application(machines connected to a LAN using wifi)?.


Solution

  • You can achieve it by following code,

    this code is useful in java so not sure but it will work for android also.

    public void getAllNodes(String subnet)
    {

          int pingTime=1000;
          String nodeName = "";
          for (int i=1;i<254;i++)
          {
               String host=subnet + "." + i;
                if (InetAddress.getByName(host).isReachable(pingTime))
                {
                     nodeName += host;
                }
          }
    }

    Just call this method like getAllNodes("192.168.0");