iOS Question Get Broadcast Address for B4i

Nitin Joshi

Active Member
Licensed User
Longtime User
I am using following code in B4A to get broadcast address of the network. However, as JavaObject is not supported in B4i, i want sub for B4i. Thank you.

B4A Get BroadCast Address:
Private Sub Get_Broadcast_Address As String

    Dim niIterator As JavaObject

    niIterator = niIterator.InitializeStatic("java.net.NetworkInterface").RunMethod("getNetworkInterfaces", Null)

    Do While niIterator.RunMethod("hasMoreElements", Null)

        Dim ni As JavaObject = niIterator.RunMethod("nextElement", Null)

        If ni.RunMethod("isLoopback", Null) = False Then

            Dim addresses As List = ni.RunMethod("getInterfaceAddresses", Null)

            For Each ia As JavaObject In addresses

                Dim broadcast As Object = ia.RunMethod("getBroadcast", Null)

                If broadcast <> Null Then

                    Dim b As String = broadcast

                    Return b.SubString(1)

                End If

            Next

        End If

    Loop

    Return ""

End Sub
 

Alexander Stolte

Expert
Licensed User
Longtime User
 
Upvote 0

Nitin Joshi

Active Member
Licensed User
Longtime User
Thanks, there are 2 subs. Both should be used? Can u please elaborate or explain. I am a learner...

And can u please help me know Map is what? How to convert in string?
 
Upvote 0
Top