I've been trying to lock the navigation bar on Android for 3 weeks so that the user can't send my activity to background. I need to do this to get my lock screen app more secure (I know that writing a custom lock screen is not the best idea but it's a requirement).
I've tried immersive mode, system dialogs, flags on decor view, onKeyDown, onBackPressed (this one works for the back button), reorder_tasks and moving my task to the front (this only works when I click on recent apps) and the usage API.
I've found this app: https://play.google.com/store/apps/details?id=com.wow.keypad.lock.screen which does EXACTLY what I need to do but I don't know how they did it.
Could anyone please help me?
I need a permanent solution like the one these guys from WOW have done.
Thanks!!!
How To Hide Navigation Bar Permanently In Android Activity
It looks like something like this has already been tackled. Your main task would not be to lock the nav bar, as much as just hide it so that the user cannot access it.
Related
In Flutter, we can SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive); to make the app fullscreen (i.e. hide Android system status bar and nav bar).
However, I observed that, if the user manually swipes from bottom of screen upwards, the system bars will re-appear again. The big problem is, Flutter code has no way to notice that. If we can get notified that this is changed, we can, for example, make the "go fullscreen" button appear again, such that users can go fullscreen again when they want.
Therefore, is there any approaches to get the current status of whether the status bar or nav bar is showing? Or even better, can we get a callback fired when it changes?
Thanks for any suggestions!
Oops I find the answer after digging into source code: setSystemUIChangeCallback.
It is a bit weird that I did not find it by googling... So anyway I just leave this question here, in case anyone has the same question as me he can find this StackOverflow answer.
Hello,
I need do fullscreen in android 4.0 (I must hide back button, home...)
I used android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
but it doesn't work.
Homebutton and backbutton cannot be hidden...
Users always need to have access to these buttons, so the black bar will always be on the screen
Like write K_Anas in a relative question, it is not possible hide Homebutton and backbutton in Android 4.0, for security reasons and because is a simply anti-pattern solution.
You can use SYSTEM_UI_FLAG_HIDE_NAVIGATION to hide the system navigation temporarily, but it will always reappear when the user touches the screen. Even the notification bar will reappear when the screen is touched.
You are not allowed to hide the system bar with the home button completely for security reasons.
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?
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.
i want make Fullscreen in android 4.0, i use android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
the action bar is disappear, but the status bar isn't appear
i use
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
before "setContentView()"
OK, FullScreen!! however, when the dialog or popupwindow show, the status bar appear again,
i read the source code and find the word :
There is a limitation: because navigation controls are so important,
the least user interaction will cause them to reappear immediately.
can i make fullscreen anytime? help me!
There is a limitation: because navigation controls are so important, the least user * interaction will cause them to reappear immediately.
In other words, Android is telling you that the limitation exists because it would be a bad idea to prevent the user from accessing the navigation controls. Doing so would surely disrupt the user experience and would probably piss off a lot of users. That said, unless you have a very good reason for doing so, you should leave it the way it is.
I have an activity here.
I want to click a button and then hide the activity GUI.
That is, GUI is needed and you can hide it by clicking a "Hide App" button. How can i
implement this "Hide App"?
Somebody help! Thanks in advance!
To do what you want within the organizational model of android, your "program" should be written as a service, not an activity. You would then have a gui that is an activity and a client of your service, which can be started (made visible) and paused/stopped (hidden) as desired.
Presumably when your user clicks the hide application button, you're going to want to show something - at the very least a show button, so the user isn't stuck without input options!
So what you really have then is two views, one with the GUI hidden.
Two approaches I can see:
Hide app calls another activity with only the UI shown that you want. When the activity is finished, use Activity.finish() to return to the original activity with the GUI
Look at ViewAnimator and its subclasses (ViewFlipper and ViewSwitcher)
You could also just enable the screen lock. ;-)
That would automatically lock the screen (hide your app). And when the user unlocked the screen (using the UI and a gesture the user is already very familiar with) he would automatically get back into your app without you needing to do any extra coding.
The additional advantage of the screen lock is that it can be be password-protected, so if the user has his screen-lock already set to a password, instead of a slide bar -- he would just get the slide password thingy.