Question: I have my custom application running on the phone and it should run 24/7, so there is one requirement to restrict launching of home screen of android phone when user clicks on Home button of the phone means if my application running on the phone and user clicks on the Home button It should not navigate to the Home screen of the phone.
It should always display my custom application on the phone.

So can anyone help me to achieve this functionality? Please share some example code so it would be helpful for me to implement.

Regards,
Piks

Answer: 
If you REALLY wanted to do this, you could make a custom launcher (home screen). Some tips for getting started are outlined [here](https://stackoverflow.com/questions/5918900/how-to-learn-custom-android-launcher), but it's not a short and simple tweak.

It would also require that your users set their launcher to your custom launcher, and then make it their default, etc. This would really only be reasonable if you have 100% configuration control over the device.

If you did go this route, however, you'd be able to handle every case of home being pressed as well as have an easy hook for starting your 24/7 app.
If you want to lock the home button. you can do this with the help of following code. but it will work for single activity only.

@Override

```
  public void onAttachedToWindow()

    {  
           this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     
           super.onAttachedToWindow();  
    }

```