本文介绍了怎么去编程了解是否安装在我的设备中的任何TTS引擎或不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以编程知道如何获得例如设备的TTS引擎信息是否安装任何TTS引擎与否,如果再安装那些是什么,什么是每个TTS引擎所支持的不同的语言?
我必须使用Android 2.1版本(API 7级),以实现这一目标。

I would like to know programmatically how to get TTS engine info of the device for e.g. whether any TTS engine is installed or not , if installed then what are those and what are the different languages supported by each TTS engine?I have to use Android version 2.1(api level 7) to achieve this.

请帮我实现此功能。

问候,

皮克斯

推荐答案

您可以通过先发送了结果的意图检查

You can check it by first sending an intent for result

Intent intent = new Intent();
intent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(intent, 0);

然后,你可以检查一下,如果你已经安装了TTS引擎或不在的onActivityResult方法:

Then you can check it that if you have installed TTS engine or not in onActivityResult method:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 0){
    if(resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS){
    Toast.makeText(getApplicationContext(),"Already Installed", Toast.LENGTH_LONG).show();
} else {
    Intent installIntent = new Intent();
    installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
    startActivity(installIntent);
    Toast.makeText(getApplicationContext(),"Installed Now", Toast.LENGTH_LONG).show();
}

希望工程:)

这篇关于怎么去编程了解是否安装在我的设备中的任何TTS引擎或不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 01:21