小编Jos*_*ges的帖子

带有API 21的TextToSpeech

有人可以帮我使用带有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)取代.

有人可以帮我编写我的应用程序.

api android text-to-speech

18
推荐指数
4
解决办法
3万
查看次数

标签 统计

android ×1

api ×1

text-to-speech ×1