How to disable Home key button on android

Hi,Does anyone know how to disable home key button for android?I need this feature for one of my projects.anyone?

You can do it by special implement of the method onPause()… See also onKeyDown() or sth like this… Check how Startapp is showing the interstitial when home is clicked

I tried onKeyDown() before but it didn’t work.on pressing home button exits app.

You actually don’t want to do it… It’s against GP policy, you will get a ban.

I know.But its a lock screen app.Shouldn’t i use it for that?Is it against Gp?i believe showing ads on overriding home key button is non-compliant,right?

A quote from GP

UX-N3 Pressing the Home button at any point navigates to the Home screen of the device.

Reference:-> Core App Quality Guidelines | Android Developers

So, pressing the home button at ANY points should navigate to home screen… It shouldn’t bring the user to some other place, or show ads, and etc etc. Read that guideline, and following that rules makes you much much safer.

i See.Thanks for pointing those quote.And i do understand but what about apps like go locker? while you press home button the phone doesn’t get unlock instead it shows the lock screen.

You can’t detect the home button press itself but you can detect when your app is about to go to the home screen. Just put some log statements on your onStop(), onPause(), onDestroy() and see which log statements are triggered. To differentiate between home and screen off use the BroadcastReceiver with Intent.ACTION_SCREEN_OFF