【问题标题】:Show “Text-to-speech settings” page from application in Honeycomb?在 Honeycomb 的应用程序中显示“文本到语音设置”页面?
【发布时间】:2012-03-02 15:28:15
【问题描述】:

我想知道在 Honeycomb 中显示文本到语音设置页面的方式是什么。

在以前的 Android 版本中,使用操作 com.android.settings.TTS_SETTINGS 有效。现在它给出了一个类转换异常。

How show “Voice Input and Output” settings page from application

06-06 06:59:33.556: ERROR/AndroidRuntime(476): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.android.settings/com.android.settings.TextToSpeechSettings}: java.lang.ClassCastException: com.android.settings.TextToSpeechSettings cannot be cast to android.app.Activity

【问题讨论】:

  • 使用 com.android.settings.VOICE_INPUT_OUTPUT_SETTINGS 通过打开语言和输入来工作。但是有没有办法直接打开文字转语音设置呢?

标签: android android-3.0-honeycomb text-to-speech


【解决方案1】:

我花了几天时间试图通过分析 Android Settings source code on Github(在历史上的某个时间点估计是 Honeycomb)来弄清楚它,我几分钟前才开始工作!

Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
intent.putExtra(EXTRA_SHOW_FRAGMENT, "com.android.settings.TextToSpeechSettings");
intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, intent.getExtras());
startActivity(intent);

【讨论】:

  • 使用 KitKat,只需将 Fragment extra 替换为“com.android.settings.tts.TextToSpeechSettings”即可。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-07
  • 1970-01-01
相关资源
最近更新 更多