예제 #1
0
  public static VoiceRecognizer instantiateVoiceRecognizer(
      Context context, RecognizerApiListener listener, ImageButton voiceAddButton) {
    synchronized (VoiceRecognizer.class) {
      if (instance == null) {
        instance = new VoiceRecognizer();
      }
    }

    if (speechRecordingAvailable(context)) {
      if (instance.recognizerApi != null) {
        instance.recognizerApi.destroy();
      }

      instance.recognizerApi = new RecognizerApi(context);
      instance.recognizerApi.setListener(listener);
    } else {
      instance.voiceInputAssistant = new VoiceInputAssistant(voiceAddButton);
    }
    return instance;
  }
예제 #2
0
 public void destroyRecognizerApi() {
   if (instance != null && instance.recognizerApi != null) {
     instance.recognizerApi.destroy();
     instance.recognizerApi = null;
   }
 }