lowerkey
lowerkey

Reputation: 8335

How do I close a secondary Activity gracefully?

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?

Upvotes: 1

Views: 444

Answers (2)

cht
cht

Reputation: 367

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();
}

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006789

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.

Upvotes: 2

Related Questions