mahesh_prince
mahesh_prince

Reputation: 15

application should minimize on backkey press

In my application I have a requrement like, If I press backkey application should not exit(as i have only one activity in my app) instead it should minimize the app as like its happening with the home key press. Any help is appreciated..

Upvotes: 0

Views: 307

Answers (2)

Alexander
Alexander

Reputation: 48272

You can probably just save whatever you need in Activity.onSaveInstanceState() and restore the saved info in Activity.onRestoreInstanceState as in this example Saving Android Activity state using Save Instance State

Upvotes: 1

Daud Arfin
Daud Arfin

Reputation: 2499

// Add this line inside back pressed.

@Override
public void onBackPressed()
{
   moveTaskToBack(true);

}

Upvotes: 4

Related Questions