My application makes heavy use of the Text to Speech API.
It is a game which leads the player to change the orientation frequently. I do have different layouts for portrait and landscape and this is ok.
I use onRetainNonConfigurationInstance() and onCreate() to keep the state.
However, there is one fact that causes problems:
I am calling tts.shutdown() in onDestroy() which I think is necessary to free resources properly. However, this causes the current text and all queued messages to be lost when the user changes the orientation. As the Text-to-Speech object has a reference on the “old” activity, I cannot transfer it to the new activity.
How can I solve this problem?
This could be a good use for the
Applicationclass, where you initiate the TTS inonCreate()(and forget about it, as onTerminate() is not called on real devices).