Code example for TextToSpeech

Methods: shutdown, stop

0
 
    @Override 
    public void onDestroy() { 
        // Don't forget to shutdown! 
        if (mTts != null) {
            mTts.stop();
            mTts.shutdown();
        } 
 
        super.onDestroy(); 
    } 
 
    // Implements TextToSpeech.OnInitListener. 
    public void onInit(int status) {
        // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR. 
        if (status == TextToSpeech.SUCCESS) {
            // Set preferred language to US english. 
            // Note that a language may not be available, and the result will indicate this. 
            int result = mTts.setLanguage(Locale.US);
            // Try this someday for some interesting results. 
            // int result mTts.setLanguage(Locale.FRANCE);