for Android version 4 (API 14 and above), it may be possible to use: GetWindow () SetType (WindowManager.LayoutParams.TYPE_SYSTEM_ALERT) ;.
however, on the emulator it does not block the home button, so this is useless. I still don’t know if it works on real devices.
It’s possible it’s possible to use the following workaround: Install the application as a standard home screen application. if the home button was pressed when the application was active, grab it and do nothing. if the home button was pressed when the application was in the background (or closed), open the previously selected default home application.
As an alternative, I could ask the user to install a standard application to start at home as mine for each of his launches, and reset again (either to the previous one, or reset completely) after closing it.
Is it possible? if so, how?
Starting with Android Lollipop (version 5.0, which is API 21), there is a way to screen the screen, and this can be enabled by the user or application (link here ):
There are two ways to activate screen binding:
Manually: users can activate screen binding in Settings> Security> Screen Pinning and select the tasks they want to display by clicking the green icon on the replay screen. Programmatically: to activate on-screen programming, call startLockTask () from your application. If the requesting application does not own the device, the user is prompted to enter a confirmation. The device owner’s application can call the setLockTaskPackages () method, which allows applications to adjust without the user’s confirmation step.
What is he doing? read on and see:
When task lock is active, the following behavior occurs:
The status bar is empty, and user notifications and status information are hidden. The Home and Recent Apps buttons are hidden. Other applications cannot start new actions. The current application may launch a new one if this does not create new tasks. When the pinning screen is called by the device owner, the user remains locked for your application until the application calls stopLockTask (). If screen binding is an activity by another application that is not the owner of the device or the user directly, the user can exit by holding both the Back and Recent buttons.
Not only this, but according to this message, you can also switch without user confirmation, and exiting this special state will be under your application logic.
This seems like the perfect thing for a safe app for toddlers.