I've found in many examples a snippet to check the internet connection.
I'm using it, but yesterday I've found that if I've wifi on but disconnected, the script returns true.
So using serversocket connection I've added another condition.
Actually p.GetSettings ("wifi_on") could detect only if wifi is on, right ?
To check if it is connected I should check serversocket.GetMyWifiIP , as Erel suggested elsewhere in this forum.
Is it correct ? Thanks
I'm using it, but yesterday I've found that if I've wifi on but disconnected, the script returns true.
So using serversocket connection I've added another condition.
Actually p.GetSettings ("wifi_on") could detect only if wifi is on, right ?
To check if it is connected I should check serversocket.GetMyWifiIP , as Erel suggested elsewhere in this forum.
Is it correct ? Thanks
B4X:
Sub CheckConnection As Boolean
Dim p As Phone
If (p.GetDataState == "CONNECTED") Then
Return True
End If
If (p.GetSettings ("wifi_on") == 1) Then
Dim s As ServerSocket
Log(s.GetMyWifiIP)
If (s.GetMyWifiIP="127.0.0.1") Then
Return False
Else
Return True
End If
End If
If (p.GetDataState == "DISCONNECTED") Then
Return False
End If
If (p.GetDataState == "SUSPENDED") Then
Return False
End If
End Sub