The way you should do it, in your activity:
Toast.makeText(this,"Thanks for using the app",Toast.LENGTH_SHORT).show();
finish();
Forget System.exit
Frage
I have a quit()
method that I am using. I use a toast to print out "thank you for using this app". On the next line I do a system.exit(0);
and when I run the app, the toast doesn't show before the system exits the app. Is there a way to fix this?
Lösung
The way you should do it, in your activity:
Toast.makeText(this,"Thanks for using the app",Toast.LENGTH_SHORT).show();
finish();
Forget System.exit
Andere Tipps
You could run a thread that waits for the duration of your Toast
.-
Thread thread = new Thread(){
@Override
public void run() {
try {
Thread.sleep(WAIT_TIME_IN_MILLIS);
} catch (Exception e) {
e.printStackTrace();
}
}
};
thread.start();