Android Question AND OR Operator provide an error

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Hi all,

with the below code, I want to check, if my device is online or not.

B4X:
    CurrentWiFiIp = server.GetMyWifiIP
    CurrentMobileIp = server.GetMyIP
    If CurrentWiFiIp = "127.0.0.1" Or CurrentWiFiIp.Contains(":") And CurrentMobileIp = "127.0.0.1" Or CurrentMobileIp.Contains(":") Then
        Msgbox("Not connected to wireless or mobile data network.","Yamutec")
        Activity.Finish
        Return
    End If

WiFI is ON Mobile data is OFF
CurrentWiFiIp = 192.168.178.78
I not get the MsgBox result: it works

WiFi is OFF Mobile data is ON
CurrentMobileIp = 101.25.12.3
I get the MsgBox result: it not works

Why?
 

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
ok now it work.
B4X:
CurrentWiFiIp = server.GetMyWifiIP
    CurrentMobileIp = server.GetMyIP
    If (CurrentWiFiIp = "127.0.0.1" Or CurrentWiFiIp.Contains(":")) And (CurrentMobileIp = "127.0.0.1" Or CurrentMobileIp.Contains(":")) Then
        Msgbox("Not connected to wireless or mobile data network.","Yamutec")
        Activity.Finish
        Return
    End If
 
Upvote 0
Top