How to disable home button in Android like lock screen apps do?
<p>I know this question is asked many times but I found that none of the solution is working.
I tried the code given below... </p>

<pre><code>   protected void onPause() {
   super.onPause();
    Intent intent = new Intent(this,LockActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT |Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    }
</code></pre>

<p>What it does is that it bring the current activity again to front when android home screen is launched but it takes almost 3-4 seconds to bring activity againt to front when home screen is launched.  </p>

<p>I have used some lock screen apps which don't even start the home screen when home button is clicked. I want to achieve something like that. </p>

<p>I have also used onUserLeavesHint method, onKeyDown method and onKeyDispatch method but none of them worked for me.</p>

<p>And please don't answer or comment like it is not possible to disable home button in Android. For such answers or comments I would suggest you to go through some Lock Screen apps on PlayStore. Also I found a working app on github along source code. It was working on my phone and the app used disableKeyguard but when I do the same in my app it doesn't work (disableKeyguard is deprecated but I use @supress warnings("deprecation")).</p>