You should move your call to SpeechWhenMotion()
from onCreate()
to the onInit()
method from TextToSpeech.OnInitListener
. The whole point of the TextToSpeech.OnInitListener
is that you get the callback to onInit()
when the initialisation is complete.
You are correct that calling it in onCreate() is too early - you must wait for onInit().