iOS Question How do I check if airplane mode is on?

davepamn

Active Member
Licensed User
Longtime User
B4X:
b4a:
    Dim oPhone As Phone

        If oPhone.IsAirplaneModeOn=True Then

            bRetVal=False

            Return(bRetVal)

        End If
This b4a code does not work for b4i

B4X:
b4a:
If oPhone.GetSettings("wifi_on")<>1 Then

            bRetVal=False

            Return(bRetVal)

        EndIf

How do I determine if Wifi is on in b4i
 

davepamn

Active Member
Licensed User
Longtime User
B4X:
Sub Class_Globals
    Dim myLan As ServerSocket
end sub
Sub PingServer As Boolean

    Dim bRetVal As Boolean=False

    Dim sDeviceIP As String

    sDeviceIP=myLan.GetMyIP

    If sDeviceIP<>"127.0.0.1" Then

            bRetVal=True

            Return(bRetVal)

    End If

    sDeviceIP=myLan.GetMyWifiIP

    If sDeviceIP="127.0.0.1" Then

            bRetVal=False

            Return(bRetVal)

    End If
return(bRetVal)
end sub


I need to be able to determine if 1) airplane mode is on and 2) if wifi is on and 3) if the phone is connected to the network.
 
Last edited:
Upvote 0

John Sparrow

Member
Licensed User
Longtime User
I have tried the code above but get the Warning "Variable 'myLan' was not initialized. (warning #11)."

When I try to initialize with "myLan.Initialize(0,"")", I get the error "_newconnection: event not found"

I have also tried to step through alternative ports by using:

Dim MyPort As Int = 0
Dim Sw As Boolean = False
Do While Sw = False
Try
myLan.Initialize(MyPort, "")
Sw = True
Catch
MyPort = MyPort + 1
End Try
Loop

but I still get the same error message.

How can I initialize the ServerSocket to avoid the warning?
 
Upvote 0
Top