private IOnActivityResult ion;
/**
* Starts listening. The Ready event will be raised when the result arrives.
*/
public void Listen(final BA ba) {
if (eventName == null)
throw new RuntimeException("VoiceRecognition was not initialized.");
Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
if (prompt != null && prompt.length() > 0)
i.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
if (language != null && language.length() > 0)
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
ion = new IOnActivityResult() {
@SuppressWarnings("unchecked")
@Override
public void ResultArrived(int resultCode, Intent intent) {
List list = new List();
if (resultCode == Activity.RESULT_OK) {
ArrayList<String> t = intent.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
if (t.size() > 0) {
list.setObject((java.util.ArrayList)t);
}
}
ba.raiseEvent(VoiceRecognition.this, eventName + "_result", list.IsInitialized(), list);
}
};
ba.startActivityForResult(ion, i);
}