1
@Override
protected void onResume() {
    super.onResume();
    if (!tts.isSpeaking()) {
        tts.speak(voiceD, TextToSpeech.QUEUE_FLUSH, null);


    }

}

/* onItin() is already implemented, in fact it works when the activity is already set up and I click a button to call it, but I want to transition to an Activity after adding in the desired voice message via putExtra, and have it speak immediately after the new activity has loaded. Additionally, I've tried debugging but the screen still wont be displayed after the super.onResume() is called.*/

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Tristen
  • 9
  • 1
  • I guess I should clarify more. It may not even be able to have the chance to speak since the activity isn't fully loaded yet. I cant tell, since its not speaking at all! But the debugger goes into the if statement so I imagine its executing the code .speak() for the TextToSpeech object namely tts. – Tristen Jun 21 '18 at 12:52
  • https://stackoverflow.com/questions/7924296/how-to-use-onwindowfocuschanged-method this made certain that the activity layout was ready and loaded, onWindowFocusedChanged() with the super overrided – Tristen Jun 21 '18 at 14:03
  • how are you initializing your tts ? and where are you doing it – pop Jun 21 '18 at 15:07
  • I declared the tts before the onCreate() and initialized it inside the onCreate(). On the Android Developer page they even say that onResume() may not be enough to tell if the screen is fully loaded, which is what I assumed I wanted. They talk about the onWindowFocusedChanged() which I used and it worked for the tablet but not my phone. I introduced a handler in the method, inserted the code, and it finally worked for the phone. – Tristen Jun 21 '18 at 15:15

0 Answers0