2

I am developing few Android apps, and I would like to provide possibility (assuming that phone supports) to 'read' the text - in Spanish app it would be Spanish voice, in French - French, respectively.

Can I somehow made one of two things:

  1. Check if this particular language is available?
  2. If it is not available - download it or give user possibility to download it?

Are there any patterns for it?

4

1 回答 1

2

1) You can easily check whether a requested language is available using built in methods.

TextToSpeech tts = new TextToSpeech(this, this);

//Use this to get the default locale
tts.isLanguageAvailable(Locale.getDefault());

//Otherwise hardcode the language you want to check for
tts.isLanguageAvailable(Locale.FRENCH());

2) You can also give the user the possibility to download it by firing off an Intent for download

Intent installIntent = new Intent();
            installIntent
                    .setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            startActivity(installIntent);
于 2013-01-24T11:32:37.503 回答