1

I'm currently working on an app for blind people. What I need is to prevent users from accidentally going outside of my app, so I'm trying to overlay/replace/hide soft buttons in Android 4. I know this must be possible because it is used for example in MXPlayer (you can "lock" screen when playing video).

I've tried to override all three buttons (back,home,recent apps). No problem with back and home, but I couldn't figure out how to override(disable) recent apps. I've tried solution described here without success.

Next idea was to overlay the entire screen. I've successfully created system overlay mentioned in this question, but I didn't find out how to overlay my soft buttons.

Do you have any idea how to solve this problem without rooting the phone and using custom ROM?

edit: I've also tried hiding the buttons with SYSTEM_UI_FLAG_LOW_PROFILE(turns buttons into dots) and SYSTEM_UI_FLAG_HIDE_NAVIGATION(hides buttons till next touch). Unfortunately this also doesn't solve my problem because after touch buttons work as usual. Maybe there's a way how to catch "unhiding" a override showing them again?

Community
  • 1
  • 1
Micer
  • 8,731
  • 3
  • 79
  • 73
  • Why don't you just hide the buttons instead of disabling them? – qwerty Feb 16 '13 at 13:19
  • This is what I'm doing now, but the problem is when I hide them (or turn into "dots"), after the touch they appear and they can be used as usual. – Micer Feb 16 '13 at 13:27

1 Answers1

3

From Android docs :

The SYSTEM_UI_FLAG_LOW_PROFILE flag replaces the STATUS_BAR_HIDDEN flag. When set, this flag enables “low profile" mode for the system bar or navigation bar. Navigation buttons dim and other elements in the system bar also hide. Enabling this is useful for creating more immersive games without distraction for the system navigation buttons.

The SYSTEM_UI_FLAG_VISIBLE flag replaces the STATUS_BAR_VISIBLE flag to request the system bar or navigation bar be visible.

The SYSTEM_UI_FLAG_HIDE_NAVIGATION is a new flag that requests the navigation bar hide completely. Be aware that this works only for the navigation bar used by some handsets (it does not hide the system bar on tablets). The navigation bar returns to view as soon as the system receives user input. As such, this mode is useful primarily for video playback or other cases in which the whole screen is needed but user input is not required.

Kiran Kumar
  • 1,192
  • 8
  • 10
  • When I use SYSTEM_UI_FLAG_LOW_PROFILE, buttons are turned into the "dots", but it is still possible to touch them and use as usual. Using SYSTEM_UI_FLAG_HIDE_NAVIGATION hides buttons, but when users touches the screen they again appear and can be used. What is more user thinks he interacted with the phone by touch, but the touch was used to unhide the buttons. Maybe there's a way how to catch the touch used for unhide, but I could find anything. :( – Micer Feb 16 '13 at 13:39
  • Yes, its not possible to do this with the SDK. You might have to root the device or load a custom Android. – Kiran Kumar Feb 16 '13 at 13:41
  • But as you can see in MXPlayer(see the link in my question), it must be somehow possible. When you turn the "lock" on during the video play, the only way how to interact with phone is to click on the little button in the corner. Soft buttons are prevented from using. – Micer Feb 16 '13 at 13:44