This SO question shows how to get access to the Results in your SpeechListener
. These results are available in the Results()
method.
As for the ability to perform tasks, you should have some kind of handler that will start the necessary services depending on the text. This handler could use intents to communicate with the services. For example, here is how you could react to the user saying "Call Bob" (based off link above):
@Override
public void onResults(Bundle results) {
ArrayList<String> voiceResults = results
.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
if (voiceResults == null) {
Log.e(TAG, "No voice results");
} else {
for (int i = 0; i < voiceResults.size(); ++i) {
if( voiceResults[i].contains("Call") )
for( int j = i+1; j < matches.size(); ++j )
if( voiceResults[j].contains("Bob") )
{
//Get Bob's phone number, using [this][2]
String bobNumber = "123 123 1234";
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+bobNumber));
startActivity(callIntent);
break;
}
}
}
}