You can lock the back button by overwriting dispatchKeyEvent() in your Activity class and return true if event.getKeyCode() is equal to KeyEvent.KEYCODE_BACK . But you cannot block the Home button from going to the home page.
I heard of some kind of cheating where you register your application as the recipient of the intent android.intent.category.HOME . This will cause the Android OS to load your activity if the user clicks the home button. If you can make this work, you can load the "actual" home screen if the user has entered the correct password. However, this approach is likely to behave differently on different devices and versions of Android, and it probably would not do anything to stop the Hold-Home task list.
The bottom line is that the Android OS was designed to prevent everything that you are trying to do: the application should not be able to control the phone and not start other applications (especially the phone).
Aaron C Oct 17 '10 at 18:18 2010-10-17 18:18
source share