Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自TextToSpeech的Android死对象异常_Android_Exception_Text To Speech - Fatal编程技术网

来自TextToSpeech的Android死对象异常

来自TextToSpeech的Android死对象异常,android,exception,text-to-speech,Android,Exception,Text To Speech,请问有人知道是什么导致了这个异常吗? (LogCat截图) 这就是我把短信叫做“说话”的方式 public void say(String text, Context context, String utteranceID){ if(mTts == null){ this.text = text; mTts = new TextToSpeech(context, (OnInitListener) helper); } else{

请问有人知道是什么导致了这个异常吗? (LogCat截图)

这就是我把短信叫做“说话”的方式

public void say(String text, Context context, String utteranceID){
    if(mTts == null){
        this.text = text;

        mTts = new TextToSpeech(context, (OnInitListener) helper);

    }
    else{
        map.clear();
        map.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, utteranceID);
        mTts.speak(text, TextToSpeech.QUEUE_FLUSH, map);
    }
}
TextToSpeech实际上可以正常工作(但正如您所看到的:),但由于我的应用程序经常使用TTS,我在自定义帮助器类中保留TTS实例。有一段时间我遇到了异常。顺便说一句,有时它只是工作,有时UI冻结一段时间,然后抛出异常。(整个过程都是支持盲操作的UI的一部分)


实际上,这是可能的解决方案。但是在查看堆栈跟踪之后,我认为我的问题不同了

您应该检查上下文值以及调用say()的位置和时间。可能上下文被破坏,因此DeadObjectException。