I have an application, when it launches I have to disable all the buttons on Android device, I succeeded in disabling end call and others. I need to disable home button click. It should not produce any action on click.
Any suggestions highly appreciated
Navigate to Android > Restrictions > Basic and click on Configure. Under Allow Device Functionality, you'll have the options to disable Home/Power button. Home Button-Uncheck this option to restrict users from using the Home Button. Power Off-Uncheck this option to restrict users from turning their devices off.
This example demonstrates how do I in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.
Add following code to your activity:
@override public void onAttachedToWindow() { this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); super.onAttachedToWindow(); }
Edit:
This works in all older version of android. But will not work in ICS
and jelly bean and will give you crash in app
What does this 4 line java code means in android application?
I'm pretty sure Toddler Lock just uses a BroadcastReciever and listens for Intent.ACTION_MAIN
and the category Intent.CATEGORY_HOME
- that's why when you first launch it, it tells you to check the "use this application as default" box, and makes you select toddler lock.
So, it's not really blocking the Home button at all, it's just setting itself up as the default broadcast receiver for:
Intent i = new Intent(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_HOME);
When you launch Toddler Lock, it probably sets an internal flag, and if you press the home button, it just brings the window to the front. If the flag is not set, it probably launches Launcher explicitly.
I hope that makes sense. It's just a theory, but I'm almost 100% sure that's how it's done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With