有人能帮我使用API 21的TTS吗?所有可用的示例都已在版本21中弃用。
这是我的代码,在最后一行出现错误:
Calendar cal = Calendar.getInstance();
cal.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
String text = sdf.toString();
btn.setText("Ouvir as Horas");
TextToSpeech tts = new TextToSpeech(NightClock.this,(TextToSpeech.OnInitListener) NightClock.this);
tts.setLanguage(Locale.US);
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
在Android开发者文档中提到这个方法已经被弃用并替换为:
speak(CharSequence text, int queueMode, Bundle params, String utteranceId) 这个方法从API级别21开始已经被替换为speak(CharSequence, int, Bundle, String)。
能有人帮忙编写我的应用程序吗?