杀死应用时停止朗读

pull/328/head
gedoor 4 years ago
parent 0358ec673b
commit 7c55a715a7
  1. 7
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt

@ -1,6 +1,7 @@
package io.legado.app.service package io.legado.app.service
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Intent
import android.speech.tts.TextToSpeech import android.speech.tts.TextToSpeech
import android.speech.tts.UtteranceProgressListener import android.speech.tts.UtteranceProgressListener
import io.legado.app.R import io.legado.app.R
@ -40,6 +41,12 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
upSpeechRate() upSpeechRate()
} }
override fun onTaskRemoved(rootIntent: Intent?) {
super.onTaskRemoved(rootIntent)
clearTTS()
stopSelf()
}
private fun initTts() { private fun initTts() {
ttsInitFinish = false ttsInitFinish = false
textToSpeech = TextToSpeech(this, this) textToSpeech = TextToSpeech(this, this)

Loading…
Cancel
Save