Search code examples
androidaudiosdkmedia-playervoice

How to stop Android TextToSpeech when there is a phone call come in


My android app got rejected by Amazon because of this reason.

I have this TextToSpeech playing while the phone call come in. They wanted me to stop playing. How do I do that?


Solution

  • In your service or activity that implement TextToSpeech register for PhoneStateListener and in your PhoneStateListener in onCallStateChanged call the TextToSpeech class stop() method for state = TelephonyManager.CALL_STATE_RINGING.