MainActivity has leaked ServiceConnection android.speech.SpeechRecognizer$Connection@414ee400 that was originally bound here

☆樱花仙子☆ 提交于 2019-12-01 15:50:00

I think problem may be at line:

sr.destroy();

If sr be null, you get NullPointerException, and

super.onDestroy();

Dont has been called. Try do next:

if(sr!=null)
{
    sr.destroy();
}

or:

try{
        sr.destroy();
} 
 catch (Exception e)
{
 Log.e(TAG,"Exception:"+e.toString());
}

The problem was the most trivial ever: I declared the SpeechRecognizer two times, one for the class and another inside the onCreate() method. The variable was initialized only in the function scope, so outside the function sr was always null.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!