如何在speechrecognizer android中获取错误8后再次重启监听?

时间:2017-05-29 10:46:38

标签: android speech-recognition

我已经尝试过这段代码,但是它没有工作,在收到错误8后,它没有再听,我该怎么办?

@Override
public void listen() {
    myHandler.post(new Runnable() {
    @Override
    public void run() {
        sr.startListening(i); // here i is Intent,SpeechRecognizer sr;
        Log.d("message","start listening");
    }
});

}

@Override
public void onError(int error) {
    Log.d("message","error occurred! "+error);
    if(error==8) {
        sr.destroy();
        myHandler.post(new Runnable() {
         @Override
          public void run() {
            sr.startListening(i);
            Log.d("message","again start listening");
        }
    });
 }
}

0 个答案:

没有答案