I am writing an action that speaks to the user, and I really would like to block TextToSpeech initialization - or timeout. How can I make my thread wait?
I tried:
while (! mIsTtsReady || i>limit) try { Thread.sleep(100); i++; ... };
together with:
@Override
public void OnInit() { mIsTtsReady = true; }
But OnInit () never starts. It seems that OnInit is executing in my thread (through a message to my Looper actions?), Which is in a closed sleep () loop.
It seems wrong to put the bulk of my code ("after init") in OnInit. Moving it to Runnable, then run () and sleep as above in this runnable. But now my code is in a new thread and needs to be explicitly synchronized with the user interface, etc., And it all becomes very messy.
What is the right way - or at least the one that works :) - for this?
Thank!
source
share