I have an application in which I need to kill the application after it asks some confirmation from the user. I am using the following code snippet.
while(tts.isSpeaking());
tts.speak("Quitting application",TextToSpeech.QUEUE_FLUSH, null);
while(tts.isSpeaking());
tts.shutdown();
int pid = android.os.Process.myPid();
android.os.Process.killProcess(pid);
The tts engine is saying “quitting application”. And screen goes blank for some time. Then after that the application is restarting. I am not getting where I am going wrong.
I have tried the System.exit(0) as well. Still same thing happening. Show me the right way. I also have some problems with using tts. I can’t synchronize the speaking and many events during application run. How can I overcome this problem?
dude try
finish()it will finish activity and specify brackets . dont useinside while and to kill entire application useint pid = android.os.Process.myPid();
android.os.Process.killProcess(pid);
REMEMBER
Intent intent = new Intent(Intent.ACTION_MAIN);intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);intent.addCategory(Intent.CATEGORY_HOME);startActivity(intent);