Instant App上的文本到语音崩溃

时间:2017-08-02 23:51:12

标签: android android-instant-apps

我正在实施一个使用Android设备上提供的文字转语音功能的即时应用。我已按照Android开发博文An introduction to Text-To-Speech in Android

中详述的说明设法初始化了TextToSpeech个实例并正常运行非即时应用

我已将我的应用重构为即时应用,并确认文本到语音功能在非即时应用中正常运行。但是,在即时应用中运行以下ACTION_CHECK_TTS_DATA意图:

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

我收到以下错误:

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) 

我无法在Restricted features pageFAQ上找到有关文字转语音或类似系统服务的任何信息,这些信息无法用于Instant Apps。这是一个错误还是Instant Apps无法使用此功能?

1 个答案:

答案 0 :(得分:0)

Android Instant Apps相对较新,Restricted Features中有一个部分会告诉您不支持的功能:

  • 不支持的功能
  • 长期运行的后台服务
  • Manifest-registered broadcast receiver
  • 外部可访问的内容提供商
  • 重新约定通知
  • 内容提供商

我相信TextToSpeech是外部可访问的内容提供商或长期运行的后台服务。