mcorbeel Active Member Licensed User Longtime User Jan 31, 2019 #1 I use this piece of code to check airplane mode on an iPhone. Some users complain that it gives "True" even when they are on a network. Is there something wrong? Code: Sub Device_AirPlaneMode() As Boolean Dim R As Boolean = False Dim myLan As ServerSocket 'ignore Dim sDeviceIP As String = myLan.GetMyWifiIP If sDeviceIP = "127.0.0.1" Then R = True End If Return r End Sub
I use this piece of code to check airplane mode on an iPhone. Some users complain that it gives "True" even when they are on a network. Is there something wrong? Code: Sub Device_AirPlaneMode() As Boolean Dim R As Boolean = False Dim myLan As ServerSocket 'ignore Dim sDeviceIP As String = myLan.GetMyWifiIP If sDeviceIP = "127.0.0.1" Then R = True End If Return r End Sub
Erel B4X founder Staff member Licensed User Longtime User Jan 31, 2019 #2 Your code looks correct. In most cases it is better not to make any check and just try to connect to the desired destination. If it works it works and if not you show a message that there is no connection. Last edited: Jan 31, 2019 Upvote 0
Your code looks correct. In most cases it is better not to make any check and just try to connect to the desired destination. If it works it works and if not you show a message that there is no connection.
mcorbeel Active Member Licensed User Longtime User Jan 31, 2019 #3 Maybe so. Is my code correct for 4G too? Is should give false when not connected to wifi but connected to 4G (not airplane mode). Upvote 0
Maybe so. Is my code correct for 4G too? Is should give false when not connected to wifi but connected to 4G (not airplane mode).
Erel B4X founder Staff member Licensed User Longtime User Jan 31, 2019 #4 You are right. The code is not correct. GetMyWifiIp returns the wifi ip address. It doesn't check the cellular network status. Upvote 0
You are right. The code is not correct. GetMyWifiIp returns the wifi ip address. It doesn't check the cellular network status.
mcorbeel Active Member Licensed User Longtime User Feb 1, 2019 #5 okay, will follow your advice and check on each connection Upvote 0