6 package com.google.appinventor.components.runtime;
10 import android.content.Intent;
11 import android.os.Bundle;
12 import android.speech.RecognitionListener;
13 import android.speech.SpeechRecognizer;
15 import java.util.ArrayList;
18 implements RecognitionListener {
21 private Intent recognizerIntent;
23 private String result;
26 this.container = container;
27 this.recognizerIntent = recognizerIntent;
33 speech.setRecognitionListener(
this);
34 speech.startListening(recognizerIntent);
40 speech.stopListening();
71 int errorNumber = getErrorMessage(i);
72 speechListener.
onError(errorNumber);
77 if (bundle.isEmpty()) {
80 ArrayList<String> results = bundle.getStringArrayList(
SpeechRecognizer.RESULTS_RECOGNITION);
81 result = results.get(0);
88 if (bundle.isEmpty()) {
91 ArrayList<String> results = bundle.getStringArrayList(
SpeechRecognizer.RESULTS_RECOGNITION);
92 result = results.get(0);
98 public void onEvent(
int i, Bundle bundle) {
102 private int getErrorMessage(
int errorCode) {