I've added the following code so that audio will stop playing if an incoming call happens. But, the app crashes when I start the app. I think the problem lies with the initialize line, but I don't know what to change. I start the service when the app starts with: StartService(incomingcall) Any ideas?
B4X:
'Service module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim PSL As PhoneStateListener
Dim Player As MediaPlayerStream
End Sub
Sub Service_Create
PSL.Initialize("PSL", False)
PSL.startListeningForEvent(PSL.LISTEN_CALL_STATE)
End Sub
Sub Service_Start
End Sub
Sub Service_Destroy
End Sub
Sub PSL_onCallStateChanged (State As Int, incomingNumber As String)
Player.Pause
End Sub