/** Wrapper for start */ public void start() { if (parent != null) { parent.runOnUiThread( new Runnable() { @Override public void run() { if (wa != null) { wa.detectActivation(); } } }); } }
/** Wrapper for stoping listening */ public void stopListening() { if (parent != null) { parent.runOnUiThread( new Runnable() { @Override public void run() { if (wa != null) { wa.stopListening(); } } }); } }
/** * Init * * @param targetWords Words to track * @param parent Main Activity parent (that implements speech listener) */ public void init(String[] targetWords, MainActivity parent) { // do only once if (wa == null) { // preempt beeping noise of speech recognizer by turning it off AudioManager amanager = (AudioManager) parent.getApplicationContext().getSystemService(Context.AUDIO_SERVICE); amanager.setStreamMute(AudioManager.STREAM_SYSTEM, true); } // store parent this.parent = parent; // initialize word activator boolean needGC = (wa != null); wa = new WordActivator(parent, parent, targetWords); if (needGC) { System.gc(); } }