Android Question Check internet connection on using my app

Makumbi

Well-Known Member
Licensed User
Iam getting error
An error occurred:
(Line: 133) If WiFi_Only And WiFi_IP = "127.0.0.1" Then
java.lang.RuntimeException: Cannot parse: as boolean



B4X:
    Dim Server As ServerSocket
    Dim WiFi_IP As String
    Dim Network_IP As String
    Dim WiFi_Only As String
    Server.Initialize(21341,"Net")
    Network_IP = Server.GetMyIP
    WiFi_IP = Server.GetMyWifiIP
    Server.Close

    If WiFi_Only And WiFi_IP = "127.0.0.1" Then
        ToastMessageShow("No WiFi connection", True)
    End If
  
    If WiFi_IP = "127.0.0.1" And Network_IP = "127.0.0.1" And Not(WiFi_Only) Then
        ToastMessageShow("No Internet connection", True)
    End If
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
    Dim WiFi_IP As String = ""
    Dim Network_IP As String = ""
    Dim WiFi_Only As Boolean = True ' should be boolean if you want to check for a boolean

    If WiFi_Only And WiFi_IP = "127.0.0.1" Then
        ToastMessageShow("No WiFi connection", True)
    End If
 
    If WiFi_IP = "127.0.0.1" And Network_IP = "127.0.0.1" And Not(WiFi_Only) Then
        ToastMessageShow("No Internet connection", True)
    End If
 
Upvote 0
Top