I have written a sub that checks whether I have network connectivity - either via a local network, or a cell network:
B4X:
Sub Check_Connectivity() As Boolean
Dim phDevice As Phone
Dim sTCP As ServerSocket
Try
sTCP.Initialize(13132, "")
If sTCP.GetMyIP <> "127.0.0.1" Then
sTCP.Close
Return True
End If
sTCP.Close
If phDevice.GetNetworkType <> "UNKNOWN" Then Return True
Return False
Catch
Send_Error_Report("Check_Connectivity", LastException.Message)
Return False
End Try
The problem I am having is that I am receiving the following error report from a few of my users:
What I don't understand is where this "Invalid int:" is coming from. There are no int variables in the sub & none of the method calls take an int as a parameter, nor do they return an int. I also don't know where this " 4" value is coming from. Is this possibly a bug in the Network library, or am I missing something really obvious here?
Yeah - that's just the way I like to write my subs if they return a value. Don't know the answer to your first question (something I will have to include in my error reporting in the future), but I have had a few reports of the issue, so I'm assuming (possibly wrongly) that it's not a specific device.
The signature for the sub is:
B4X:
Sub Send_Error_Report(sSub As String, sError As String)
- although I don't think it's relevant as the exception itself is being generated in Check_Connectivity.