B4J Code Snippet external Ip

some Isp dont supply fixed Ip adresses.
It will change mostly every day.
For remote controlling you can use DynDns or NoIp.
but a adding a little code will provide you (via mail for example) the current Ip adress
B4X:
Sub publicIp
   Dim j As HttpJob
   st.Initialize
   j.Initialize("j", Me)
''   j.Download("http://checkip.dyndns.org/")
   j.Download("http://checkip.amazonaws.com/")
End Sub

Sub JobDone(Job As HttpJob)

   If Job.Success Then

     ''myip=("Ip adres=" & st.mid(Job.GetString,st.InString(Job.getstring,lenkey)+lenkeylen,15))
     myip=Job.getstring
     Log(myip)
     Log(Job.ErrorMessage)
   End If
   Job.Release

End Sub
[\code]
 
Top