java - Speech recognition not works Android -


i want display in textview using tts engine. have button:

btnparla.setonclicklistener(new view.onclicklistener() {                  @override                 public void onclick(view arg0) {                      intent = new intent(recognizerintent.action_recognize_speech);                     i.putextra(recognizerintent.extra_language_model, recognizerintent.language_model_free_form);                     i.putextra(recognizerintent.extra_prompt, "say something");                      try {                         startactivityforresult(i, voice_rec);                         //txt.settext("");                     } catch (activitynotfoundexception e){                         toast t = toast.maketext(getapplicationcontext(), "errore", toast.length_short);                         t.show();                     }                 }                 }); 

and then:

@override     protected void onactivityresult(int requestcode, int resultcode, intent data)     {         // todo: implement method         super.onactivityresult(requestcode, resultcode, data);          switch (resultcode) {             case voice_rec: {                     if (resultcode == activity.result_ok) {                         arraylist<string> dico = data.getstringarraylistextra(recognizerintent.extra_results);                         resultlist.settext(dico.get(0));                      }                     break;                 }                   }         } 

where resultlist textview declared in oncreate resultlist = (textview) findviewbyid(r.id.list);. button works not save in textview. not display say. what's wrong?

the parameter voice_rec in startactivityforresult(i, voice_rec); requestcode not resultcode. change switch condition switch (resultcode) switch (requestcode).

    switch (requestcode) {         case voice_rec: {             if (resultcode == activity.result_ok) {                 arraylist<string> dico =  data.getstringarraylistextra(recognizerintent.extra_results);                 resultlist.settext(dico.get(0));              }             break;         }     } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -