I have service class that implement SpeechRecognization by using SpeechRecognizer. There is broadcast receiver class which will start this service when an event is occurred. And then the SpeechRecognizer will start listening in the service.
I got the runtime exception in doing this process.
01-28 09:15:09.601: E/JavaBinder(23476): *** Uncaught remote exception! (Exceptions are not yet supported across processes.)
01-28 09:15:09.601: E/JavaBinder(23476): java.lang.RuntimeException: SpeechRecognizer should be used only from the application's main thread
01-28 09:15:09.601: E/JavaBinder(23476): at android.speech.SpeechRecognizer.checkIsCalledFromMainThread(SpeechRecognizer.java:319)
01-28 09:15:09.601: E/JavaBinder(23476): at android.speech.SpeechRecognizer.startListening(SpeechRecognizer.java:260)
01-28 09:15:09.601: E/JavaBinder(23476): at com.reader.MainSpeakerService.startRecognization(MainSpeakerService.java:181)
01-28 09:15:09.601: E/JavaBinder(23476): at com.reader.MainSpeakerService.onUtteranceCompleted(MainSpeakerService.java:255)
01-28 09:15:09.601: E/JavaBinder(23476): at android.speech.tts.UtteranceProgressListener$1.onDone(UtteranceProgressListener.java:57)
01-28 09:15:09.601: E/JavaBinder(23476): at android.speech.tts.TextToSpeech$Connection$1.onDone(TextToSpeech.java:1443)
01-28 09:15:09.601: E/JavaBinder(23476): at android.speech.tts.ITextToSpeechCallback$Stub.onTransact(ITextToSpeechCallback.java:63)
01-28 09:15:09.601: E/JavaBinder(23476): at android.os.Binder.execTransact(Binder.java:388)
01-28 09:15:09.601: E/JavaBinder(23476): at dalvik.system.NativeStart.run(Native Method)
According to the android doc, the service uses your application's main thread
. The service run on the main thread. I confuse that why this exception is happened in service.