PhoneEvents_AirplaneModeChanged keeps crashing

ThELyNX77

New Member
Licensed User
Longtime User
Hi I have the following code in a service module.

My aim to to ensure certain settings on the handset are as i require them for my app and if they are not then set them (samsung Galaxy Y)

I need to make sure GPS is activated, AirplaneMode is disabled and Data connection is activated.

So far this works great for the GPS but AirplaneMode crashes.

Anyone have any idea why ?

PHP:
#Region Module Attributes
   #StartAtBoot: False
#End Region

'Service module
Sub Process_Globals
        Dim PE As PhoneEvents
   Dim AC As AnswerCall
   Dim PhoneId As PhoneId

   Dim GPS1 As GPS
   Dim TGL As Toggle

End Sub
Sub Service_Create 
    PE.InitializeWithPhoneState("PE",PhoneId)
   AC.Initialize("AnswerCall")
   GPS1.Initialize("GPS")
   TGL.Initialize()

   Log("Service created")
End Sub

Sub Service_Start
   Log("Service started.")

   GPS1.Start(1000,0)
   
'   TGL.TurnGPSOn
'   TGL.TurnDataConnectionOn
'   TGL.TurnAirplaneModeOff


End Sub

Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
    Log("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber)
    Log(Intent.ExtrasToString)
   ToastMessageShow(IncomingNumber,False)
   AC.LetPhoneRing(3)
   If AC.isRinging == True Then
      AC.AnswerPhone
   End If
   AC.enableSpeakerphone
   
End Sub

Sub PE_AirplaneModeChanged (State As Boolean, Intent As Intent)
   ToastMessageShow("AirplaneMode State " & State ,True)
   Log("AirplaneMode State " & State)

   If State = True Then
      TGL.TurnAirplaneModeOff
   End If

End Sub

Sub GPS_UserEnabled (Enabled As Boolean)
   'ToastMessageShow("GPS State " & Enabled ,True)
   Log("GPS State " & Enabled)

   If Enabled = False Then
      TGL.TurnGPSOn
   End If
   
End Sub

Sub Service_Destroy
   Log("Service ended.")
    
End Sub
 

agraham

Expert
Licensed User
Longtime User
What does "crash" mean? You need to post details of what is happening if you expect to get help.

Always, always look in the logs - filtered and unfiltered when unexpected things happen. There is probably an error and a stack trace there that is relevant to your problem.
 
Upvote 0

ThELyNX77

New Member
Licensed User
Longtime User
I wish i could look in the logs. I am developing on an S3 with custom firmware and USB debugging is not available.

B4A-Bridge requires a bluetooth for WiFi connection and activating airplane mode breaks this and logs aint viewable.

The TGL.TurnAirplaneModeOff command works fine from an activity but when i put it in the service module all I get is a toast msg saying "AirplaneMode state true" then another "AirplaneMode state false" then "Unfortunately, application has stopped working", whenever I activate AirplaneMode. And AirplaneMode is still active.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I wish i could look in the logs. I am developing on an S3 with custom firmware and USB debugging is not available.

B4A-Bridge requires a bluetooth for WiFi connection and activating airplane mode breaks this and logs aint viewable.

The TGL.TurnAirplaneModeOff command works fine from an activity but when i put it in the service module all I get is a toast msg saying "AirplaneMode state true" then another "AirplaneMode state false" then "Unfortunately, application has stopped working", whenever I activate AirplaneMode. And AirplaneMode is still active.

With JellyBean, it is now impossible to toggle the Airplane mode programmatically. So you have to keep in mind that all your efforts will be ruined on a recent device.
 
Upvote 0
Top