TextToSpeech : deprecated speak function in API Level 21

前端 未结 2 1584
遥遥无期
遥遥无期 2021-02-18 13:25

I try to use a TextToSpeech in my app,

String text = editText.getText().toString();
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);

But the fu

2条回答
  •  南旧
    南旧 (楼主)
    2021-02-18 13:59

    String text = editText.getText().toString();
    
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        tts.speak(text,TextToSpeech.QUEUE_FLUSH,null,null);
    } else {
        tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
    }
    

提交回复
热议问题