1

I managed to create a secondary Activity, but now I wonder how I can close it again.

public void button_onClick(View v){
   finish();
}

works when I'm dealing with just one Activity at a time, but how do I let the secondary Activity close the entire application?

lowerkey
  • 8,105
  • 17
  • 68
  • 102

2 Answers2

2

You don't "close the entire application" in Android, any more than you "close the entire application" in a Web app. See this answer for more on this topic.

Community
  • 1
  • 1
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

It's work for me. In the FIRST Activity:

private boolean flag = false;

@Override
protected void onResume() {
    if(!flag)
        flag = true;
    else
        finish();
    super.onResume();
}
cht
  • 367
  • 2
  • 6
  • 20