1

在我的应用程序中,我创建了一个活动。它在启动时创建一个服务。活动中有一个按钮。当它被按下时,它会触发服务使用 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 配置:

@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);
    }
}
4

0 回答 0