Best way to close your app

Hi! I’m looking for a nice way to close my app. I see many games with the “exit” button and I wanna some look it.

I have 3 Activities and I try with System.exit, Activity.finish… but not work good, because close mi main activity but then goes to my third activity :S

I do the next:

Activity 1: Whe i go to the activity 2, i call finish activity 1 and startActivity 2.
Activity 2: Whe i go to the activity 1, i call finish activity 2 and startActivity 1.

Only one activity is “open” at the same time.

If i need save some value i use SharedPreferences or sometimes putExtra(KEY,VALUE). In this way when you click a exit button menu call finish on these activity and the app is destroyed. After the SO finish him of RAM when needed.

mmmm sounds good :slight_smile: I’m was looking for a way to close all together, but I think this will work fine for me. Thanks

Normally you should only have one Activity open at a time, as @“victor.vjj” described. But if you really want to layer multiple activities, there’s a good thread on StackOverflow.com about how to close an Android app programmatically.