0

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.

user1156041
  • 2,155
  • 5
  • 24
  • 54
  • 2
    If the service is started from the receiver, and it is not bound to an activity in the foreground, probably it is not considered to be in the app thread since it is not yet related to that process in any way – Carlos Robles Jan 28 '14 at 03:48
  • See the question and comments and then my answer at http://stackoverflow.com/questions/14940657/android-speech-recognition-as-a-service-on-android-4-1-4-2/14950616#14950616 – Hoan Nguyen Jan 28 '14 at 20:03

0 Answers0