服务未注册:android.speech.tts.TextToSpeech

时间:2015-01-02 10:49:51

标签: android

我正在测试我的可访问性应用程序。如果用户在中间关闭可访问性,则应用程序崩溃,原因是服务未注册:android.speech.tts.TextToSpeech。我在onDetachedFromWindow方法中调用了setJavaScriptEnabled(false),但是没有用。仍有错误。

我没有在webview中使用应用程序上下文,因为webview正在使用xml进行初始化。

 java.lang.IllegalArgumentException: Service not registered: android.speech.tts.TextToSpeech$Connection@49df6be0
   at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:940)
   at android.app.ContextImpl.unbindService(ContextImpl.java:1983)
   at android.content.ContextWrapper.unbindService(ContextWrapper.java:541)
   at android.speech.tts.TextToSpeech$Connection.disconnect(TextToSpeech.java:1575)
   at android.speech.tts.TextToSpeech$1.run(TextToSpeech.java:732)
   at android.speech.tts.TextToSpeech$1.run(TextToSpeech.java:727)
   at android.speech.tts.TextToSpeech$Connection.runAction(TextToSpeech.java:1595)
   at android.speech.tts.TextToSpeech.runAction(TextToSpeech.java:629)
   at android.speech.tts.TextToSpeech.runActionNoReconnect(TextToSpeech.java:615)
   at android.speech.tts.TextToSpeech.shutdown(TextToSpeech.java:727)
   at com.android.org.chromium.content.browser.accessibility.AccessibilityInjector$TextToSpeechWrapper.shutdownInternal(AccessibilityInjector.java:462)
   at com.android.org.chromium.content.browser.accessibility.AccessibilityInjector.removeAccessibilityApis(AccessibilityInjector.java:296)
   at com.android.org.chromium.content.browser.accessibility.JellyBeanAccessibilityInjector.removeAccessibilityApis(JellyBeanAccessibilityInjector.java:97)
   at com.android.org.chromium.content.browser.accessibility.AccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(AccessibilityInjector.java:162)
   at com.android.org.chromium.content.browser.ContentViewCore.setInjectedAccessibility(ContentViewCore.java:2884)
   at com.android.org.chromium.content.browser.ContentViewCore.setAccessibilityState(ContentViewCore.java:2875)
   at com.android.org.chromium.content.browser.ContentViewCore$16.onChange(ContentViewCore.java:2839)
   at android.database.ContentObserver$NotificationRunnable.run(ContentObserver.java:180)
   at android.os.Handler.handleCallback(Handler.java:733)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:157)
   at android.app.ActivityThread.main(ActivityThread.java:5356)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
   at dalvik.system.NativeStart.main(NativeStart.java)

1 个答案:

答案 0 :(得分:2)

最后它已经解决了。我必须从xml文件移动所有webview并动态添加它们并传递应用程序上下文。

WebView webView = new WebView(getApplicationContext());