服务中的android tts未能连续说话

时间:2013-06-02 17:46:03

标签: android service text-to-speech logcat

在我的应用中,我创建了一项活动。它在启动时创建服务。活动中有一个按钮。当它被按下时,它触发服务使用TTS重复以10秒的间隔说出一个句子。我可以听到重复的句子。然后我按回家隐藏活动,然后关闭屏幕。我还能听到这句话。但大约半小时后,我再也听不到了。然后我看看logcat:

06-02 20:56:30.237: W/dalvikvm(32503): Unable to resolve superclass of Lcom/example/myact/myservice$2; (84)

06-02 20:56:30.237: W/dalvikvm(32503): Link of class 'Lcom/example/myact/myservice$2;' failed

06-02 20:56:30.237: E/dalvikvm(32503): Could not find class 'com.example.myact.myservice$2', referenced from method com.example.myact.myservice.setTts

06-02 20:56:30.237: W/dalvikvm(32503): VFY: unable to resolve new-instance 515 (Lcom/example/myact/myservice$2;) in Lcom/example/myact/myservice;

06-02 20:56:30.237: D/dalvikvm(32503): VFY: replacing opcode 0x22 at 0x0006

06-02 20:56:30.237: D/dalvikvm(32503): VFY: dead code 0x0008-0042 in Lcom/example/myact/myservice;.setTts (Landroid/speech/tts/TextToSpeech;)V

06-02 20:56:30.237: D/dalvikvm(32503): VFY: dead code 0x0044-0065 in Lcom/example/myact/myservice;.setTts (Landroid/speech/tts/TextToSpeech;)V

06-02 20:56:30.247: I/dalvikvm(32503): DexOpt: unable to
 optimize instance field ref 0x001b at 0x4a in Lcom/example/myact/myservice;.setTts

06-02 20:56:30.247: I/dalvikvm(32503): DexOpt: unable to optimize instance field ref 0x001b at 0x58 in Lcom/example/myact/myservice;.setTts

有人能向我解释发生了什么吗?提前谢谢。

对于tts config in serivce:

@SuppressWarnings("deprecation")
@Override
public void onInit(int status) {
    // TODO Auto-generated method stub

    if(status == TextToSpeech.SUCCESS)
    {

        setTts(_tts);

    }       
}

@SuppressWarnings("deprecation")
public void setTts(TextToSpeech tts)
{
     if (Build.VERSION.SDK_INT >= 15)
    {
        tts.setOnUtteranceProgressListener(new UtteranceProgressListener()
        {
            @Override
            public void onDone(String utteranceId)
            {
                onDoneSpeaking(utteranceId);
            }

            @Override
            public void onError(String utteranceId)
            {
            }

            @Override
            public void onStart(String utteranceId)
            {
            }
        });                     
    }
    else
    {

        tts.setOnUtteranceCompletedListener(this);
    }
}

0 个答案:

没有答案