了解应用程序上下文

时间:2020-05-06 03:05:36

标签: java android android-context

我刚接触Android / Java,需要一些指导。

有人可以在下面解释为什么无法解析getApplicationContext()的原因吗?

private void readText(final String s) {
    textToSpeech = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
        @Override
        public void onInit(int status) {
            if (status == TextToSpeech.SUCCESS){
                textToSpeech.speak(s, TextToSpeech.QUEUE_FLUSH, null);
            }
        }
    });
}

0 个答案:

没有答案