In B4XPage, I found these two ways to detect if there is an Internet connection. The problem, both are only for Android. "PhoneEvents" does not exist in the internal iPhone library or possibly I did not find it
Easy way:
Sub Class_Globals
Private pEvents As PhoneEvents
End Sub
Public Sub Initialize
pEvents.Initialize("PhoneStatus")
End Sub
Private Sub PhoneStatus_ConnectivityChanged (NetworkType As String, State As String, Intent As Intent)
If State = "CONNECTED" Then
'Code
Else If State <> "CONNECTED" Then
'Code
End If
End Sub
Hi all, With this library you will have the following possibility. Currently version v1.5 (2021/05/23) 1️. Check the status of the airplane mode 2. Check internet connection status 3. Check the roaming status of the device 4. Check VPN connection status 5. Check Data State status 6. Get the...
In B4XPage, I found these two ways to detect if there is an Internet connection. The problem, both are only for Android. "PhoneEvents" does not exist in the internal iPhone library or possibly I did not find it
Easy way:
Sub Class_Globals
Private pEvents As PhoneEvents
End Sub
Public Sub Initialize
pEvents.Initialize("PhoneStatus")
End Sub
Private Sub PhoneStatus_ConnectivityChanged (NetworkType As String, State As String, Intent As Intent)
If State = "CONNECTED" Then
'Code
Else If State <> "CONNECTED" Then
'Code
End If
End Sub
Hi all, With this library you will have the following possibility. Currently version v1.5 (2021/05/23) 1️. Check the status of the airplane mode 2. Check internet connection status 3. Check the roaming status of the device 4. Check VPN connection status 5. Check Data State status 6. Get the...
This library was inspired and based on WaitForTheInternet by César Pérez https://github.com/ouvigna/WaitForTheInternet Your application will be able to get through an event, as it connects to the internet via Wifi or 3G, without the need to be checking all the time, not consuming battery...
This library wraps Apple's code: https://developer.apple.com/library/archive/samplecode/SimplePing/Introduction/Intro.html Usage example: Sub Class_Globals Private Root As B4XView Private xui As XUI Private Pinger As SimplePing End Sub Public Sub Initialize End Sub Private Sub...
Other alternatives which I use in my apps.
which has the possibility of checking other ports.
Lib: Network, JNetwork y iNetwork
Test in B4A and B4J
B4X:
Wait For (Ping("google.com", 80)) Complete (Status As Boolean)
Log(Status)
Wait For (Ping("172.66.43.61", 80)) Complete (Status As Boolean) 'cnn.com
Log(Status)
Wait For (Ping("cnn.com", 80)) Complete (Status As Boolean) 'cnn.com
Log(Status)
Wait For (Ping("localhost", 80)) Complete (Status As Boolean)
Log(Status)
B4X:
Public Sub Ping(Host As String, Port As Int) As ResumableSub
Dim Socket As Socket
Socket.Initialize("Socket")
Socket.Connect(Host, Port, 60 * DateTime.TicksPerSecond)
Wait For Socket_Connected (Successful As Boolean)
Return Successful
End Sub