My GDK app starts by opening a standard Activity that overrides onCreateOptionsMenu and inflates a basic menu.xml. You click an item then it calls startActivity with the intent of the next activity. After a few of these activities I want the last activity to present a menu option to close the application. However everything I tried simply kills the activity, not the application. What's the right way to close an application that's not being started by a service?
Here's what I've tried:
finish();
process.killProcess(android.os.Process.myPid());
System.exit(0);
All of these simply close the current activity and show the activity behind it.
Ok I figured out a solution. I added this to each activity:
@Override
protected void onPause() {
super.onPause();
finish();
}
So now when I call finish on the last one the application closes. Not sure if this is the best thing to do but it works.