geschlossen Ich bin auf der Suche nach allen Arten von Funktionen wie onDestroy. aber ich suche genau nach einer Funktion, die ausgeführt wird, wenn die App vom Benutzer geschlossen wird. Ich benutze Text-Sprache in meiner Anwendung, aber während es spricht, wenn Benutzer App schließen (egal wie, erzwinge Stop oder Exit-Taste in der App, ...) wird es weitersprechen. Gibt es dafür eine spezielle Funktion?wie man Text-Rede stoppt, wenn Android-App von Benutzer
Vielen Dank im Voraus
attirant
Code:
private boolean t1State = false;
private TextToSpeech t1;
private void start_voice(String text)
{
t1=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if(status != TextToSpeech.ERROR) {
t1.setLanguage(Locale.UK);
}
}
});
String msg = "Voice Started";
Toast.makeText(getApplicationContext(), msg,Toast.LENGTH_SHORT).show();
t1.speak(text, TextToSpeech.QUEUE_FLUSH, null);
t1State = true;
}
private void stop_voice()
{
String msg;
if(t1 !=null) {
t1.stop();
}
msg = "Voice has been Stopped";
Toast.makeText(getApplicationContext(), msg,Toast.LENGTH_SHORT).show();
t1State = false;
}
Verwenden Sie Service? – Bek
nein, es gibt keine Dienste in App – attirant
können Sie Ihren Code teilen – Bek