Android Question PhoneEvents no longer triggering

ddk1

Member
Licensed User
I have an app that's been working for years, but just stopped working, presumably because of some Android update (v11)
I would use TTS to speak some text, detect when speech finished via PhoneEvents TextToSpeechFinish event, then do something. TextToSpeechFinish recently just decided to stop triggering.
Manifest still set to android:targetSdkVersion="28" to fend off other issues on external folders I use.

A simple example of code would be
B4X:
Sub Globals
    Dim TTS1 As TTS
    Dim PE As PhoneEvents
    Dim mPhId As PhoneId
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        PE.InitializeWithPhoneState("PE",  mPhId)    'can't remember why I used InitializeWithPhoneState rather than plain Initialize but it makes no difference
    End If
    TTS1.Initialize("")  
End Sub
Sub btn_Click
    TTS1.Speak("testing", False)
End Sub
Sub PE_TextToSpeechFinish (Intent As Intent)
    Log("TextToSpeechFinish")
End Sub

I'm getting around it by using
B4X:
Sub btn_Click
    TTS1.Speak("testing", False)
    Dim jo As JavaObject = TTS1
    Do While jo.RunMethod("isSpeaking",Null) = True
      Sleep(250)
    Loop
    Log("TextToSpeechFinish")
End Sub
But I wondered if anyone knows why PhoneEvents stopped working, and maybe my workaround will help someone else.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…