有人可以帮我使用带有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);
Run Code Online (Sandbox Code Playgroud)
在Android开发人员中,它表示不推荐使用此方法,并将其替换为:
speak(String text,int queueMode,HashMap params)此方法在API级别21中已弃用.从API级别21开始,由speak(CharSequence,int,Bundle,String)取代.
有人可以帮我编写我的应用程序.