android - How do you populate an edittext field instead of a listview when using speech recognition? -
i using code google's sample voice recognition class. write top 5 results listview want top result posted in edittext field. possible? or possible populate listview automatically copy results edittext field?
any appreciated.
if want 1 result back, should specify in intent use start voice recognition activity:
private void startvoicerecognitionactivity() { intent intent = new intent(recognizerintent.action_recognize_speech); intent.putextra(recognizerintent.extra_calling_package, getclass().getpackage().getname()); intent.putextra(recognizerintent.extra_language_model, recognizerintent.language_model_free_form); //since want one, request 1 intent.putextra(recognizerintent.extra_max_results, 1); intent.putextra(recognizerintent.extra_language, "en-us"); startactivityforresult(intent, 1234); }
and pull single result , set edittext:
@override public void onactivityresult(int requestcode, int resultcode, intent data) { if (resultcode == activity.result_ok){ //pull of matches arraylist<string> matches = data.getstringarraylistextra(recognizerintent.extra_results); string topresult = matches.get(0); edittext edittext = findviewbyid(r.id.youredittext); edittext.settext(topresult); } }
Comments
Post a Comment