I have been struggling to get the text message (SMS) reader working well. It works fine when I send the Text-To-Speech (TTS) to the music stream and you are using the default music player. It will pause the music, play the TTS, and then resume the music. If you use most other players (like Winamp or Amazon) it does not work properly.
If you use the in-call stream, it seems to work great on the Droid phones. However, some devices using Android 2.2.0 will reboot when the TTS is done playing. They also won't play the TTS (it appears muted). Even on the Droid's something strange happens. It all seems fine until you disconnect from the device. Then your streams all go to the phone earpiece instead of the phones speaker. A quick reboot fixes it but that is very annoying.
I added another stream selection, the alarm stream, to 2.3.7. That one works quite strange. It will play through the phones speaker even when connected to a Bluetooth handsfree and A2DP device. OK, so maybe that is not so bad. However, it never pauses the music, it just permanently mutes the A2DP stream after playing the TTS.
I tried capturing AudioMode before, and then restoring after but it made no difference. I have tried reordering the calls, disabling each call one at a time, etc. I have scoured Stack Overflow and of course Google. Not sure I can totally fix this now. I have read the documentation and examples several times. It appears the audio focus has many strange bugs. Maybe it is all a timing issue? I just implemented the on focus change listener but I have not really put any code in it as I did not really see the need. Maybe I need to have this listener look for the state change before progressing to the next audio manager command.
One other strange thing I noticed is when using the in-call stream if I try to pause the music right after the TTS gets done it will keep restarting by itself. If I wait a few seconds its fine. This is part of what makes me think it could be a timing issue. Also, I used the alarm stream and it muted A2DP as explained above. Then I switch it to the music stream. After the next text was read, the A2DP stream worked fine again. So, when I make a audio focus call again, it seems to move the streams around fixing or breaking things
I am testing on both a Droid 2 and Droid 3. Both have Gingerbread.
Thoughts anyone?