Example usage for android.speech.tts TextToSpeech TextToSpeech

List of usage examples for android.speech.tts TextToSpeech TextToSpeech

Introduction

In this page you can find the example usage for android.speech.tts TextToSpeech TextToSpeech.

Prototype

public TextToSpeech(Context context, OnInitListener listener) 

Source Link

Document

The constructor for the TextToSpeech class, using the default TTS engine.

Usage

From source file:com.yangtsaosoftware.pebblemessenger.services.MessageProcessingService.java

private void loadPrefs() {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    quiet_hours = sharedPref.getBoolean(Constants.PREFERENCE_QUIET_HOURS, false);
    callQuietEnable = sharedPref.getBoolean(Constants.PREFERENCE_CALL_QUIET, false);
    read_message = sharedPref.getBoolean(Constants.PREFERENCE_READ_MESSAGE, false);
    if (read_message && myTTS == null) {
        myTTS = new TextToSpeech(this, this);
    }/*from  w  ww .j  a v a  2s  .c om*/
    if (!read_message && myTTS != null) {
        myTTS.shutdown();
        myTTSisOK = false;
    }
    if (quiet_hours) {
        String[] pieces = sharedPref.getString(Constants.PREFERENCE_QUIET_HOURS_BEFORE, "00:00").split(":");
        quiet_hours_before = new GregorianCalendar(0, 0, 0, Integer.parseInt(pieces[0]),
                Integer.parseInt(pieces[1]));
        pieces = sharedPref.getString(Constants.PREFERENCE_QUIET_HOURS_AFTER, "23:59").split(":");
        quiet_hours_after = new GregorianCalendar(0, 0, 0, Integer.parseInt(pieces[0]),
                Integer.parseInt(pieces[1]));
    }
    switch (Integer.parseInt(sharedPref.getString(Constants.PREFERENCE_MESSAGE_SCALE,
            String.valueOf(Constants.MESSAGE_SCALE_SMALL)))) {
    case Constants.MESSAGE_SCALE_SMALL:
        fChars = Constants.SMALL_LINE_CONTAIN_CHARS;
        break;
    case Constants.MESSAGE_SCALE_MID:
        fChars = Constants.MID_LINE_CONTAIN_CHARS;
        break;
    case Constants.MESSAGE_SCALE_LARGE:
        fChars = Constants.LARGE_LINE_CONTAIN_CHARS;
        break;
    }
}

From source file:bikebadger.RideFragment.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {

    switch (requestCode) {
    case MY_DATA_CHECK_CODE_REQUEST:
        // for testing
        //resultCode = TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL;
        switch (resultCode) {
        case TextToSpeech.Engine.CHECK_VOICE_DATA_PASS:
            RideManager.mTTS = new TextToSpeech(mRideManager.mAppContext, this);
            //RideManager.mTTS = null;
            Log.v(Constants.APP.TAG, "TextToSpeech installed");
            break;
        case TextToSpeech.Engine.CHECK_VOICE_DATA_BAD_DATA:
        case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_DATA:
        case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_VOLUME:
        case TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL:

            Log.e(Constants.APP.TAG, "Got a failure. Text To Speech not available");

            AlertDialog ad = new AlertDialog.Builder(getActivity()).create();
            ad.setCancelable(false);//from  w w  w. ja v  a 2s .  c  o  m
            ad.setTitle("Text To Speech Engine Not Found");
            ad.setMessage(
                    "There was a problem finding the Text To Speech Engine. Make sure it's install properly under Language and Input Settings.");
            ad.setButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            ad.show();

            // missing data, install it
            //Log.v(Constants.APP.TAG, "Need language stuff: " + resultCode);
            //Intent installIntent = new Intent();
            //installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            //startActivity(installIntent);
            break;
        }

        break;
    /* No longer used as it is deprecated. Use SimpleFileDialog instead even though it blocks.
    TODO - integrate a slick open file that includes DropBox and Drive library!
    case Constants.APP.FILE_CHOOSER_REQUEST_CODE:
            
        if (resultCode == getActivity().RESULT_OK) {
            if (data != null) {
                // Get the URI of the selected file
                final Uri uri = data.getData();
                Log.i(Constants.APP.TAG, "Uri = " + uri.toString());
                try {
                    // Get the file path from the URI
                    final String path = FileUtils.getPath(mRideManager.mAppContext, uri);
                    //Toast.makeText(getActivity(), "File Selected: " + path, Toast.LENGTH_LONG).show();
                    OpenGPXFileOnNewThreadWithDialog(path);
                   // if(isVisible())
                     //    updateUI(); // update title bar file loaded
                } catch (Exception e) {
                    Log.e("FileSelectorTestActivity", "File select error", e);
                }
            }
        }
        break;
         */
    case Constants.APP.ACTION_WAYPOINT_REQUEST_CODE:
        if (resultCode == getActivity().RESULT_OK) {
            if (data != null) {
                final Location location = data.getParcelableExtra("location");
                String command = data.getStringExtra("command");
                final String arg = data.getStringExtra("argument");

                mRideManager.AddNewWaypoint(command, arg, location);
                // enable the save menu
                mMenu.findItem(R.id.menu_item_gpx_save).setEnabled(true);
            }
        }
        break;
    case MY_MAP_CODE_REQUEST:

        if (resultCode == getActivity().RESULT_OK) {
            Log.d(Constants.APP.TAG, "Return from map");
        }
        break;
    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.nbplus.vbroadlauncher.HomeLauncherActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    // Check for the integer request code originally supplied to startResolutionForResult().
    case REQUEST_CHECK_SETTINGS:
        mIsAlreadyShownDialog = false;//w w w  . ja  v a 2  s . co m
        switch (resultCode) {
        case Activity.RESULT_OK:
            Log.i(TAG, "User agreed to make required location settings changes.");
            //startLocationUpdates();
            break;
        case Activity.RESULT_CANCELED:
            Log.i(TAG, "User chose not to make required location settings changes.");
            break;
        }
        break;

    case Constants.START_ACTIVITY_REQUEST_CHECK_TTS_DATA:
        if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
            // check korean
            mText2Speech = new TextToSpeech(this, this);
        } else {
            Log.d(TAG, "   ??.... ? ??...");
            if (mcheckText2SpeechLister != null) {
                mcheckText2SpeechLister.onCheckResult(null);
                mText2Speech = null;
            }
            showText2SpeechAlertDialog();

            LauncherSettings.getInstance(this).setIsCheckedTTSEngine(true);
        }
        break;
    }
}

From source file:com.updetector.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /**/* w w w  .  j  a va 2 s. c  o  m*/
     * Set the views
     */
    // Set the main layout
    setContentView(R.layout.activity_main);

    // get a handle to the console textview
    consoleTextView = (TextView) findViewById(R.id.console_text_id);
    consoleTextView.setMovementMethod(new ScrollingMovementMethod());

    //setup monitoring fields
    environTextView = (TextView) findViewById(R.id.environment);
    environTextView.setText(ENVIRONMENT_PREFIX + CommonUtils.eventCodeToString(lastEnvironment));
    stateTextView = (TextView) findViewById(R.id.state);

    //stateTextView.setText(STATE_PREFIX+"unknown");

    googleStateTextView = (TextView) findViewById(R.id.google_state);
    googleStateTextView.setText(GOOGLE_MOBILITY_STATE_PREFIX + "unknown");

    //indicatorTextView=(TextView) findViewById(R.id.indicator);
    //indicatorTextView.setText(INDICATOR_PREFIX);

    // set up the map view
    setupMapIfNeeded();
    //set up the location client
    setupLocationClientIfNeeded();

    /**
     * set up color coded map
     */
    if (parkingBlocks == null) {
        parkingBlocks = ParkingBlocks.GetParkingBlocks();
        showAvailabilityMap();
    }

    mTextToSpeech = new TextToSpeech(this, this);
    mCalendar = Calendar.getInstance();

    /*
     * Initialize managers
     */
    // Instantiate an adapter to store update data from the log
    /*           mStatusAdapter = new ArrayAdapter<Spanned>(
           this,
           R.layout.item_layout,
           R.id.log_text
               );*/

    // Set the broadcast receiver intent filer
    mBroadcastManager = LocalBroadcastManager.getInstance(this);

    // Create a new Intent filter for the broadcast receiver
    mBroadcastFilter = new IntentFilter(Constants.ACTION_REFRESH_STATUS_LIST);
    mBroadcastFilter.addCategory(Constants.CATEGORY_LOCATION_SERVICES);
    mBroadcastFilter.addAction(Constants.BLUETOOTH_CONNECTION_UPDATE);
    mBroadcastFilter.addAction(Constants.GOOGLE_ACTIVITY_RECOGNITION_UPDATE);
    mBroadcastManager.registerReceiver(mBroadcastReceiver, mBroadcastFilter);

    // Get the instance of the customized notification manager
    mDetectionNotificationManager = DetectionNotificationManager.getInstance(this);

    //Get the FusionManager object
    mFusionManager = new FusionManager(this);

    // Get the ClassificationManager object
    mClassificationManager = ClassificationManager.getInstance(this);

    //TODO  train classifiers if necessary
    if (Constants.IS_TRAINING_MODE) {
        int[] classifiersToBeTrained = { Constants.ACCEL_MOTION_STATE };
        for (int classifier : classifiersToBeTrained) {
            mClassificationManager.mClassfiers.get(classifier).train();
        }
    }

    //get the sensor service
    mSensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE);
    //get the accelerometer sensor
    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mSensorManager.registerListener(mSensorEventListener, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);

    mAudioRecordManager = AudioRecordManager.getInstance();

    // Get the WakeLockManager object
    mWakeLockManager = WakeLockManager.getInstance(this);
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // Get the LogManager object
    mLogManager = LogManager.getInstance(this);
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mXPSHandler = new XPS(this);
    mXPSHandler.setRegistrationUser(new WPSAuthentication("dbmc", "uic"));
    //mXPSHandler.setTiling("", 0, 0,  null);

    /**
     * Initialize IODetector
     */
    cellTowerChart = new CellTowerChart((TelephonyManager) getSystemService(TELEPHONY_SERVICE), this);
    magnetChart = new MagnetChart(mSensorManager, this);
    lightChart = new LightChart(mSensorManager, this);

    //new AggregatedIODetector().execute("");//Check the detection for the first time

    //This timer handle starts the aggregated calculation for the detection
    //Interval 1 seconds.
    Timer uiTimer = new Timer();
    mIODectorHandler = new Handler();

    /*uiTimer.scheduleAtFixedRate(new TimerTask() {
       private int walked = 0;
       @Override
       public void run() {
    mIODectorHandler.post(new Runnable() {
       @Override
       public void run() {
          if(phoneNotStill){//Check if the user is walking
             walked++;
          }
          else{
             walked = 0;
          }
          if(aggregationFinish && walked > 3){//Check if the user has walked for at least 3 second, and the previous calculation has been finish
             aggregationFinish = false;
             walked = 0;
             new AggregatedIODetector().execute("");
          }
            
       }
    });
       }
    }, 0, 1000);*/

    /**
      * Initialize fields other than managers
      */
    lastAccReading = new double[3];

    /**
      * Startup routines
      */
    // catch the force close error
    Thread.setDefaultUncaughtExceptionHandler(new UnCaughtException(MainActivity.this));

    /**
     * Start Google Activity Recognition
     */
    mGoogleActivityDetectionRequester = new GoogleActivityRecognitionClientRequester(this);
    mGoogleActivityDetectionRemover = new GoogleActivityRecognitionClientRemover(this);
    startGoogleActivityRecognitionUpdates(null);

    checkGPSEnabled();

    //test record sample
    //mAudioRecordManager.recordAudioSample("/sdcard/audio.wav");

    //Test extract features from audio files
    //String features=AudioFeatureExtraction.extractFeatures(this, "/sdcard/bus6.wav");
    //mClassificationManager.mClassfiers.get(Constants.SENSOR_MICROPHONE).classify(features);

}

From source file:org.botlibre.sdk.activity.ChatActivity.java

public void resetTTS() {
    try {//from  www .j  a  v  a2  s  . c  o m
        this.tts.stop();
    } catch (Exception exception) {
    }
    try {
        this.tts.shutdown();
    } catch (Exception exception) {
    }
    this.tts = new TextToSpeech(this, this);
}

From source file:usbong.android.likha_collection_1.UsbongDecisionTreeEngineActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == UsbongUtils.MY_DATA_CHECK_CODE) {
        /*/*from www.  j  av  a2s. co  m*/
         if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
        // success, create the TTS instance
        mTts = new TextToSpeech(this, this);
          } else {
        // missing data, install it
        Intent installIntent = new Intent();
        installIntent.setAction(
            TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
        startActivity(installIntent);
          }
        */
        if (mTts == null) {
            Intent installIntent = new Intent();
            installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            startActivity(installIntent);
        }
        mTts = new TextToSpeech(this, this);
    } else if (requestCode == UsbongUtils.EMAIL_SENDING_SUCCESS) {
        finish();
        Intent toUsbongMainActivityIntent = new Intent(UsbongDecisionTreeEngineActivity.this,
                UsbongMainActivity.class);
        toUsbongMainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(toUsbongMainActivityIntent);
        if (mTts != null) {
            mTts.shutdown();
        }
    } else if (requestCode == 1001) {
        int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
        String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
        String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");

        if (resultCode == RESULT_OK) {
            try {
                JSONObject jo = new JSONObject(purchaseData);
                String sku = jo.getString("productId");

                //edited by Mike, 20160620
                if (sku.contains("local")) {
                    UsbongUtils.hasUnlockedLocalLanguages = true; //added by Mike, 20160427
                    myPurchaseLanguageBundleListAdapter.setLocalLanguageToOwned();

                    //Reference: http://stackoverflow.com/questions/23024831/android-shared-preferences-example
                    //; last accessed: 9 June 2015
                    //answer by Elenasys
                    //added by Mike, 9 June 2015
                    SharedPreferences.Editor editor = getSharedPreferences(UsbongConstants.MY_PURCHASED_ITEMS,
                            MODE_PRIVATE).edit();
                    editor.putString(UsbongConstants.ALL_LOCAL_LANGUAGES_PRODUCT_ID, "Owned");
                    editor.commit();

                    new AlertDialog.Builder(getInstance()).setTitle("Purchase Complete!")
                            .setMessage("You have unlocked All Local Languages!")
                            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            }).show();
                } else if (sku.contains("local")) {
                    UsbongUtils.hasUnlockedForeignLanguages = true; //added by Mike, 20160427
                    myPurchaseLanguageBundleListAdapter.setForeignLanguageToOwned();

                    //Reference: http://stackoverflow.com/questions/23024831/android-shared-preferences-example
                    //; last accessed: 9 June 2015
                    //answer by Elenasys
                    //added by Mike, 9 June 2015
                    SharedPreferences.Editor editor = getSharedPreferences(UsbongConstants.MY_PURCHASED_ITEMS,
                            MODE_PRIVATE).edit();
                    editor.putString(UsbongConstants.ALL_FOREIGN_LANGUAGES_PRODUCT_ID, "Owned");
                    editor.commit();

                    new AlertDialog.Builder(getInstance()).setTitle("Purchase Complete!")
                            .setMessage("You have unlocked All Foreign Languages!")
                            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            }).show();
                } else { //for all languages
                    UsbongUtils.hasUnlockedLocalLanguages = true; //added by Mike, 20160427
                    UsbongUtils.hasUnlockedForeignLanguages = true; //added by Mike, 20160427
                    myPurchaseLanguageBundleListAdapter.setAllLanguagesToOwned();

                    //Reference: http://stackoverflow.com/questions/23024831/android-shared-preferences-example
                    //; last accessed: 9 June 2015
                    //answer by Elenasys
                    //added by Mike, 9 June 2015
                    SharedPreferences.Editor editor = getSharedPreferences(UsbongConstants.MY_PURCHASED_ITEMS,
                            MODE_PRIVATE).edit();
                    editor.putString(UsbongConstants.ALL_LANGUAGES_PRODUCT_ID, "Owned");
                    editor.commit();

                    new AlertDialog.Builder(getInstance()).setTitle("Purchase Complete!")
                            .setMessage("You have unlocked All Languages!")
                            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            }).show();
                }
            } catch (JSONException e) {
                //TODO: fix this
                //alert("Failed to parse purchase data.");
                e.printStackTrace();
            }
            /*
                            //refresh the menu options
                           AlertDialog purchaseLanguagesListAlertDialog = purchaseLanguagesListDialog.create();
                           purchaseLanguagesListAlertDialog.invalidateOptionsMenu();
                    
                           AlertDialog setLanguageAlertDialog = setLanguageDialog.create();
                           setLanguageAlertDialog.invalidateOptionsMenu();              
            */
            purchaseLanguageListAlertDialog.dismiss();
        }
    }
}

From source file:de.rosche.spectraTelemetry.SpectraTelemetry.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_CONNECT_DEVICE:
        if (resultCode == Activity.RESULT_OK) {
            String address = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
            BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
            mSerialService.connect(device);
            mEnablingBT = true;//from   w ww  .j a v a 2 s .  c  om
        }
        break;
    case REQUEST_ENABLE_BT:
        if (resultCode == Activity.RESULT_OK) {
            mEnablingBT = true;
        } else {
            finishDialogNoBluetooth();
        }
        break;
    case MY_DATA_CHECK_CODE:
        if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
            if (tts == null) {
                tts = new TextToSpeech(this, this);
            }

        } else {
            Intent installIntent = new Intent();
            installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            startActivity(installIntent);
        }
        break;
    case REQUEST_PREFS:
        if (resultCode == Activity.RESULT_OK) {
        }
        break;
    }
}

From source file:usbong.android.retrocc.UsbongDecisionTreeEngineActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == UsbongUtils.MY_DATA_CHECK_CODE) {
        /*// ww  w . j  a  v a  2  s  . c  om
         if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
        // success, create the TTS instance
        mTts = new TextToSpeech(this, this);
          } else {
        // missing data, install it
        Intent installIntent = new Intent();
        installIntent.setAction(
            TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
        startActivity(installIntent);
          }
        */
        if (mTts == null) {
            Intent installIntent = new Intent();
            installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            startActivity(installIntent);
        }
        mTts = new TextToSpeech(this, this);
    } else if (requestCode == UsbongUtils.EMAIL_SENDING_SUCCESS) {
        finish();
        Intent toUsbongMainActivityIntent = new Intent(UsbongDecisionTreeEngineActivity.this,
                UsbongMainActivity.class);
        toUsbongMainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(toUsbongMainActivityIntent);
        if (mTts != null) {
            mTts.shutdown();
        }
    } else if (requestCode == 1001) {
        int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
        String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
        String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");

        if (resultCode == RESULT_OK) {
            try {
                JSONObject jo = new JSONObject(purchaseData);
                String sku = jo.getString("productId");
                if (sku.contains("local")) {
                    UsbongUtils.hasUnlockedLocalLanguages = true; //added by Mike, 20160427
                    myPurchaseLanguageBundleListAdapter.setLocalLanguageToOwned();

                    //Reference: http://stackoverflow.com/questions/23024831/android-shared-preferences-example
                    //; last accessed: 9 June 2015
                    //answer by Elenasys
                    //added by Mike, 9 June 2015
                    SharedPreferences.Editor editor = getSharedPreferences(UsbongConstants.MY_PURCHASED_ITEMS,
                            MODE_PRIVATE).edit();
                    editor.putString(UsbongConstants.ALL_LOCAL_LANGUAGES_PRODUCT_ID, "Owned");
                    editor.commit();

                    new AlertDialog.Builder(getInstance()).setTitle("Purchase Complete!")
                            .setMessage("You have unlocked All Local Languages!")
                            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            }).show();
                } else {
                    UsbongUtils.hasUnlockedForeignLanguages = true; //added by Mike, 20160427
                    myPurchaseLanguageBundleListAdapter.setForeignLanguageToOwned();

                    //Reference: http://stackoverflow.com/questions/23024831/android-shared-preferences-example
                    //; last accessed: 9 June 2015
                    //answer by Elenasys
                    //added by Mike, 9 June 2015
                    SharedPreferences.Editor editor = getSharedPreferences(UsbongConstants.MY_PURCHASED_ITEMS,
                            MODE_PRIVATE).edit();
                    editor.putString(UsbongConstants.ALL_FOREIGN_LANGUAGES_PRODUCT_ID, "Owned");
                    editor.commit();

                    new AlertDialog.Builder(getInstance()).setTitle("Purchase Complete!")
                            .setMessage("You have unlocked All Foreign Languages!")
                            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            }).show();
                }
            } catch (JSONException e) {
                //TODO: fix this
                //alert("Failed to parse purchase data.");
                e.printStackTrace();
            }
            /*
                            //refresh the menu options
                           AlertDialog purchaseLanguagesListAlertDialog = purchaseLanguagesListDialog.create();
                           purchaseLanguagesListAlertDialog.invalidateOptionsMenu();
                    
                           AlertDialog setLanguageAlertDialog = setLanguageDialog.create();
                           setLanguageAlertDialog.invalidateOptionsMenu();              
            */
            purchaseLanguageListAlertDialog.dismiss();
        }
    }
}

From source file:jmri.enginedriver.throttle.java

private void setupTts() {
    if (!prefTtsWhen
            .equals(getApplicationContext().getResources().getString(R.string.prefTtsWhenDefaultValue))) {
        if (myTts == null) {
            Intent checkTTSIntent = new Intent();
            //                checkTTSIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
            //                startActivityForResult(checkTTSIntent, MY_TTS_DATA_CHECK_CODE);
            lastTtsTime = new Time();
            lastTtsTime.setToNow();/* ww w  .  j av  a  2  s  .c om*/

            myTts = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
                @Override
                public void onInit(int status) {
                    if (status != TextToSpeech.ERROR) {
                        myTts.setLanguage(Locale.getDefault());
                    } else {
                        Toast.makeText(getApplicationContext(),
                                getApplicationContext().getResources().getString(R.string.toastTtsFailed),
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
        }
    }
}