Text to Speech crash on Instant Apps

笑着哭i 提交于 2019-12-12 11:06:04

问题


I'm in the process of implementing an instant app that makes use of the Text to Speech functionality available on Android devices. I have managed to get a TextToSpeech instance initialized and working correctly for non-instant apps by following the instructions detailed in the Android dev blog post An introduction to Text-To-Speech in Android

I have refactored my app to be an instant app and have confirmed that the Text to Speech functionality is working in the non-instant app. However when running the following ACTION_CHECK_TTS_DATA intent in the instant app:

val checkIntent = Intent()
checkIntent.action = TextToSpeech.Engine.ACTION_CHECK_TTS_DATA
activity.startActivityForResult(checkIntent, initilizeTtsRequestCode)

I get the following error:

FATAL EXCEPTION: main
 Process: [PACKAGE_NAME_REDACTED], PID: 9500
 java.lang.RuntimeException: Unable to start activity ComponentInfo{[PACKAGE_NAME_REDACTED]/[PACKAGE_NAME_REDACTED].ui.SNTMainActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.speech.tts.engine.CHECK_TTS_DATA }
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
     at android.app.ActivityThread.-wrap11(Unknown Source:0)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
     at android.os.Handler.dispatchMessage(Handler.java:105)
     at android.os.Looper.loop(Looper.java:164)
     at android.app.ActivityThread.main(ActivityThread.java:6541)
     at java.lang.reflect.Method.invoke(Native Method)
     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
  Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.speech.tts.engine.CHECK_TTS_DATA }
     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1936)
     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1615)
     at android.app.Activity.startActivityForResult(Activity.java:4472)
     at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
     at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:65)
     at android.app.Activity.startActivityForResult(Activity.java:4430)
     at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:711)
     at [PACKAGE_NAME_REDACTED].SNTTtsManager.initialize(SNTTtsManager.kt:92)
     at [PACKAGE_NAME_REDACTED].ui.SNTMainActivity.onStart(SNTMainActivity.kt:96)
     at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1333)
     at android.app.Activity.performStart(Activity.java:6992)
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2780)
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
     at android.app.ActivityThread.-wrap11(Unknown Source:0) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
     at android.os.Handler.dispatchMessage(Handler.java:105) 
     at android.os.Looper.loop(Looper.java:164) 
     at android.app.ActivityThread.main(ActivityThread.java:6541) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

I can't find any information about Text to Speech or similar system services not being available to Instant Apps on the Restricted features page nor FAQ. Is this a bug or is this feature not available to Instant Apps?


回答1:


Android Instant Apps is relatively new, there is a section in Restricted Features that tells you the unsupported features:

  • Unsupported features
  • Long-running background services
  • Manifest-registered broadcast receivers
  • Externally accessible content providers
  • Re-engagement notifications
  • Content providers

And I believe that TextToSpeech is either an externally accessible content provider or a Long-running background service.



来源:https://stackoverflow.com/questions/45472709/text-to-speech-crash-on-instant-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!