Code example for TextToSpeech

Methods: shutdown, getCurrentEngine

        // Keep track of the previous engine that was being used. So that 
        // we can reuse the previous engine. 
        // Note that if TextToSpeech#getCurrentEngine is not null, it means at 
        // the very least that we successfully bound to the engine service. 
        mPreviousEngine = mTts.getCurrentEngine();
        // Step 1: Shut down the existing TTS engine. 
        if (mTts != null) {
            try { 
                mTts = null;
            } catch (Exception e) {
                Log.e(TAG, "Error shutting down TTS engine" + e);
        // Step 2: Connect to the new TTS engine. 
        // Step 3 is continued on #onUpdateEngine (below) which is called when 
        // the app binds successfully to the engine.