pa1pal
pa1pal

Reputation: 753

system.exit(0) returned to the previous screen not closing the entire app on single click

I made three .xml files before the activity_main.xml and set a timer of 5 sec one by one for each xml file by using thread.So it takes 15 sec to reach to the main activity.

I have a problem in my EXIT button I use

system.exit(0);          //behaving similar as finish()

but it returns me to the previous xml file not from the entire app. I want to exit from entire app in a single click.

Upvotes: 2

Views: 1310

Answers (2)

Mads Frandsen
Mads Frandsen

Reputation: 523

In your Manifest.xml, you should add android:noHistory="true" in your <activity> tags. Additionally, you should not call system.exit(0), but instead just use finish().

By doing this, the activities will not be added to the back stack, and therefore, pressing the exit button (or the back button) will let the user exit the app.

Upvotes: 2

Amit Gupta
Amit Gupta

Reputation: 8939

Try Like this

moveTaskToBack(true);

For reference moveTaskToBack

Upvotes: -1

Related Questions