Android examples for android.speech.tts:TextToSpeech
Checks availability of speech recognizing Activity
import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; import android.speech.RecognizerIntent; import android.widget.Toast; import java.util.ArrayList; import java.util.List; public class Main{ /**//from ww w .j a va 2 s. c o m * Checks availability of speech recognizing Activity * * @param callerActivity ? Activity that called the checking * @return true ? if Activity there available, false ? if Activity is absent */ private static boolean isSpeechRecognitionActivityPresented( Activity callerActivity) { try { // getting an instance of package manager PackageManager pm = callerActivity.getPackageManager(); // a list of activities, which can process speech recognition Intent List activities = pm.queryIntentActivities(new Intent( RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); if (activities.size() != 0) { // if list not empty return true; // then we can recognize the speech } } catch (Exception e) { } return false; // we have no activities to recognize the speech } }