I know this question is asked many times but I found that none of the solution is working. I tried the code given below...
protected void onPause() {
What you could do is override the home key function like this:
@Override public boolean onKeyDown(int keyCode, KeyEvent event)
{
if(keyCode == KeyEvent.KEYCODE_HOME)
{
//The Code Want to Perform.
}
});
Then you should be able to prevent the user to go back to home screen using this button. Hope that works for you.
EDIT: The problem with overriding the home button is it is considered as a security hole by Google, so each time someone finds a way to override it Google patches this "hole".