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; }
public void destroyRecognizerApi() { if (instance != null && instance.recognizerApi != null) { instance.recognizerApi.destroy(); instance.recognizerApi = null; } }