I am new to Java and and not sure how to do this correctly.
I have a String variable textMain
and I would like to pass it into a new object TextToSpeech
. Is it possible? If so, how to do it?
I have to declare this variable outside of the object, unfortunately this object does not 'see' this variable.
String textMain = "text text";
textToSpeechSystem = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
speak(textMain); // textMain doesn't visible
}
}
});
Sorry if I wrote something wrong, I don't know the correct nomenclature yet.