Android Question WiFi & List Address-ip Connect

MarcoRome

Expert
Licensed User
Longtime User
Hi all
Exist a library or another to know the list ip connected to WiFi ???

Thank you all in advance
 

MarcoRome

Expert
Licensed User
Longtime User
Hi NJDude i see that exist a lot library.
But i dont see that is possible get ALL address Ip connect in Wifi.
Example ServerSocket.GetMyIp get ip device.
But for know all Ip connected in Wifi ?

maybe this code work i will try this evening:

B4X:
Sub GetPropInfo As String
  Dim i As Int
  Dim P As Phone
  Dim sb As StringBuilder
  Dim PropData() As String
  Dim sWifi, sModel, sSdk, sVersion, sIP, sMask, sGate, sD1, sD2 As String
 
  sb.Initialize
  P.Shell("getprop", Null, sb, Null)
  PropData = Regex.Split(CRLF,sb.ToString)
 
  For i = 0 To PropData.Length - 1
 
      ' What is the Wifi Interface called?
      If PropData(i).Contains("[wifi.interface]") Then
        sWifi = PropData(i)
        sWifi = sWifi.Replace("[","")
        sWifi = sWifi.Replace("]","")
        sWifi = sWifi.SubString(sWifi.IndexOf(" ")).Trim
        Exit
      End If
   
  Next
 
  If sWifi.Length > 0 Then
 
      ' Get the model, android version, sdk version, ip, subnet mask, gateway, dns1 and dns2
      For i = 0 To PropData.Length - 1
 
        If PropData(i).Contains("[ro.product.model]") Then
            sModel = PropData(i)
            sModel = sModel.Replace("[","")
            sModel = sModel.Replace("]","")
            sModel = sModel.SubString(sModel.IndexOf(" ")).Trim
        End If
       
        If PropData(i).Contains("[ro.build.version.sdk]") Then
            sSdk = PropData(i)
            sSdk = sSdk.Replace("[","")
            sSdk = sSdk.Replace("]","")
            sSdk = sSdk.SubString(sSdk.IndexOf(" ")).Trim
        End If
       
        If PropData(i).Contains("[ro.build.version.release]") Then
            sVersion = PropData(i)
            sVersion = sVersion.Replace("[","")
            sVersion = sVersion.Replace("]","")
            sVersion = sVersion.SubString(sVersion.IndexOf(" ")).Trim
        End If
       
        ' *******************************************************************
       
        If PropData(i).Contains("[dhcp." & sWifi & ".ipaddress]") Then
            sIP = PropData(i)
            sIP = sIP.Replace("[","")
            sIP = sIP.Replace("]","")
            sIP = sIP.SubString(sIP.IndexOf(" ")).Trim
        End If
       
        If PropData(i).Contains("[dhcp." & sWifi & ".mask]") Then
            sMask = PropData(i)
            sMask = sMask.Replace("[","")
            sMask = sMask.Replace("]","")
            sMask = sMask.SubString(sMask.IndexOf(" ")).Trim
        End If
       
        If PropData(i).Contains("[dhcp." & sWifi & ".gateway]") Then
            sGate = PropData(i)
            sGate = sGate.Replace("[","")
            sGate = sGate.Replace("]","")
            sGate = sGate.SubString(sGate.IndexOf(" ")).Trim
        End If
       
        If PropData(i).Contains("[dhcp." & sWifi & ".dns1]") Then
            sD1 = PropData(i)
            sD1 = sD1.Replace("[","")
            sD1 = sD1.Replace("]","")
            sD1 = sD1.SubString(sD1.IndexOf(" ")).Trim
        End If
       
        If PropData(i).Contains("[dhcp." & sWifi & ".dns2]") Then
            sD2 = PropData(i)
            sD2 = sD2.Replace("[","")
            sD2 = sD2.Replace("]","")
            sD2 = sD2.SubString(sD2.IndexOf(" ")).Trim
        End If
 
      Next
   
      Return  "Model: " & sModel & CRLF & _
            "Android v/ " & sVersion & CRLF & _
            "SDK v/ " & sSdk & CRLF & CRLF & _
            "Wifi Interface: " & sWifi & CRLF & _
            "IP Address: " & sIP & CRLF & _
            "Subnet Mask: " & sMask & CRLF & _
            "Default Gateway: " & sGate & CRLF & _
            "DNS #1: " & sD1 & CRLF & _
            "DNS #2: " & sD2 & CRLF
 
  Else
      Return "Wifi Interface not found."
  End If
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…