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

Discussion in 'iOS Questions' started by davepamn, Mar 30, 2015.

  1. davepamn

    davepamn Active Member Licensed User

    Code:
    b4a:
        
    Dim oPhone As Phone

            
    If oPhone.IsAirplaneModeOn=True Then

                bRetVal=
    False

                
    Return(bRetVal)

            
    End If
    This b4a code does not work for b4i

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

                bRetVal=
    False

                
    Return(bRetVal)

            EndIf
    How do I determine if Wifi is on in b4i
     
  2. davepamn

    davepamn Active Member Licensed User

    Code:
    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: Mar 31, 2015
  3. Erel

    Erel Administrator Staff Member Licensed User

    The code you posted looks correct.
     
  4. tucano2000

    tucano2000 Active Member Licensed User

    What is the declaration myLan in the above code ?
     
  5. davepamn

    davepamn Active Member Licensed User

    Code:
    Sub Class_Globals
    Dim myLan As ServerSocket
    end sub
     
  6. tucano2000

    tucano2000 Active Member Licensed User

    Thanks
     
  7. John Sparrow

    John Sparrow Member Licensed 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?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Please use [code]code here...[/code] tags when posting code.

    You don't need to initialize it.
    You can add an 'ignore comment on the relevant line to suppress the warning.
     
  9. John Sparrow

    John Sparrow Member Licensed User

    OK Thanks
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice