Q:

Quit Application when home button pressed.

I have a security program, so i need to quit the application when the HOME button pressed. But I know the HOME button action cannot be implemented. 
Then, I know that I can use 
android:noHistory="true"

to do it. But I have used 
startActivityForResult(intent, 0);

to call a new activity. When the activity called back by 
this.setResult(RESULT_OK, intent);
this.finish();

The original activity has already quit. 
How can I quit the application when the HOME button pressed, but the startActivityForResult will not quit the activity? 

A:

As a general rule, you shouldn't be quitting your app like this. It breaks the intuitive workflow most people expect when using an app. However, if you really want to do this, override onPause() and onStop() and implement the code to quit in those. Remember to call super() in your overridden method.

