private static class StopRecListenerThread extends Thread {
SpeechRecognizer recognizer;
StopRecListenerThread(SpeechRecognizer recognizer) {
this.recognizer = recognizer;
}
@Override
public void run() {
if (!this.recognizer.stop())
Log.d(TAG, "StopRecListenerThread: listener was not stopped");
else
Log.d(TAG, "StopRecListenerThread: listener was stopped");
}
}
I have an object that needs to be stopped but it can’t be done on the main thread. I pass the object to a static Thread
class and stop it from there. Is this a valid use for Thread
or should I revert to AsyncTask
? I’m trying to understand Thread
better.