title: Android TTS speech synthesis error when screen is lock
body: <p>I am writing an Android app that needs to speak using text-to-speech (<a href="https://developer.android.com/reference/android/speech/tts/TextToSpeech.html" rel="nofollow noreferrer">TTS</a>).</p>
  
  <pre><code>tts.speak("Some text", TextToSpeech.QUEUE_ADD, null, UTT_ID);
  </code></pre>
  
  <p>This works perfectly fine when the screen is on.</p>
  
  <p>If the screen is off &amp; lock, the Activity will wake up the screen (upon creation) and show itself (intentional). This is accomplished with</p>
  
  <pre><code>getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                  WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
                  WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  </code></pre>
  
  <p>And this works fine too.</p>
  
  <p>However, when the Activity is created and shown when the screen had been off...text-to-speech will not create any sound.</p>
  
  <p>Looking at log, I see</p>
  
  <pre><code>TTS     : synthesizeWithoutLoadingVoice() failed
  </code></pre>
  
  <p>Googling this error message gave nothing.
  Anyone know what I did wrong here?</p>