Android Question Phone state listener not responding

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

I pasted the following code in my service module but when I use the phone it does not execute.

I also tried to type the sub in manually by typing the word "sub" followed by a space then tab to bring up the pop up list be the phone state listener was not in the list so I'm assuming I did something wrong.

I made sure the listener is in the library manager and it was there. I also declared it and initialised it and started it listening.

I thought that just pasting sample sub routine code in would work but it looks like that's not the correct way. Could you tell me how set it up so the listener will run?

Thanks.

B4X:
' In process_globals

    Dim PslPhoneState As PhoneStateListener

B4X:
' In service_create

    PslPhoneState.Initialize("PhoneState", False)
    PslPhoneState.startListening

B4X:
' Listeners.
'-----------
' Callback invoked when device call state changes.
' Idle = 0
' Ringing = 1
' OFFHook = 2
'-------------------------------------------------
Sub PslPhoneState_onCallStateChanged (State As Int, incomingNumber As String)

    ToastMessageShow("Call state is: " & State, False)

    If State <> 0 Then
        ToastMessageShow("Phone is in use.", False)
    End If
End Sub
 

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

Just switched to the Phone library from Erel and that works so I will not use the Phone State Listener library.

Truly,
Emad
 
Upvote 0
Top