Android Question TTS speak in a call


Well-Known Member
Licensed User
Longtime User
Generally I know that TTS is stopping automaticall while in a call .
If you are in a call for example more that 20 de minute and the OS is deciding in the meantime to kill one of the processes that uses tts ,on process restart new TTS is initialised and all text is read after service start without restriction !

I thought that i must store the event "in a call " in a variable and store it to dir.internal and see the previous state when service start to inhibit the tts.speak event .

Any other ideas ?
I do not now if android handles automatic the TTS.speak event while in a call.


Well-Known Member
Licensed User
Longtime User
I guess catching the phone state with ev_PhoneStateChanged (state As String, IncomingNumber As String, Intent As Intent) is not the so easy or
it depends on what do you want to do ..
If you are storing the state in a variable then you must write your value to sd-card and read it back on your service start with actually becomes a bit
complicated , the reason I think that is that your service will eventually be killed and will start again on your schedule so it might happen that your
service will start just when you are in a call.

I found a refection example and please correct me if I am wrong.

 Sub hsmes_MessageReceived (From As String, Body As String) As Boolean

Dim state As Int 'v20

if state=0 then
'your code is safe to run here
end if

end sub

'returns the current device call state
'0 = Device call state: No activity.
'1 = Device call state: Ringing. A new call arrived and is ringing or waiting. In the latter case, another call is already active.
'2 = Device call state: Off-hook. At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.
Sub GetCallState() As Int
    Dim r As Reflector
   Dim TelephonyManager As Object
   r.Target = r.GetContext
    TelephonyManager = r.RunMethod2("getSystemService", "phone", "java.lang.String")
    r.Target = TelephonyManager
   Return r.RunMethod( "getCallState")
End Sub
Last edited:
Upvote 0