How to hide the soft-key bar on Android phone? - android

 
When my app starts, I'd like to hide the soft keys bar (in red rectangle) to have a larger screen.
How can I hide it?
Do I need to show the bar purposely when the app quits? Or it will restore itself automatically after the app quits?
Android 4.1, with no hardware keys on phone front.

I know its late but it is the right answer so what you are trying to do is what called immersive mode. for (API 19)
check out: https://developer.android.com/training/system-ui/immersive.html
The code that you were asking for is:
#Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}

Try
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
From official doc
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.
The behavior of the nav bar is app dependent IIRC, so it should show again after the user leaves your app.

Related

Android: Never show Support Action Bar

There is a way to completly hide the support action bar, even if the user scroll down from top to bottom? Never show it.
This solution works but only temporary
getSupportActionBar().hide();
I've tried also:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE);
and
android:theme="#style/Theme.AppCompat.NoActionBar"
or similar.
When the user scroll down, the bar re-appear.
I need it because i'm making my personal launcher and I've got my personal support action bar
When the user scroll down, the bar re-appear.
It seems to me it's not available to completely disable/hide status bar.
From SYSTEM_UI_FLAG_IMMERSIVE_STICKY docs:
When system bars are hidden in immersive mode, they can be revealed temporarily with system gestures, such as swiping from the top of the screen. These transient system bars will overlay app’s content, may have some degree of transparency, and will automatically hide after a short timeout.
Use this
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

How to hide the navigation bar in android?

so i'm writing an app in which i would like the navigation bar in a specific
activity to be hidden...and i managed to do so...but my problem is when the
user scrolls down the notification bar...when that happens...the navigation bar
re-appears...how can i solve this problem?
final int mUIFlag = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_FULLSCREEN;
//View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
getWindow().getDecorView().setSystemUiVisibility(mUIFlag);
when the user scrolls down the notification bar...when that happens...the navigation bar re-appears
I think this behavior is normal and intended as UI design of Android.
Whenever a user swipes-down upper edge or swipes-up bottom edge of screen, both system bar and navigation bar re-appear. Then after a few seconds, they are both disappear again. So as to the user can access system bar or navigation bar whenever they want even if screen is in immersive mode.
can i do anything to disable this? or maybe only hide it
No, generally (without root access) you can't. Only you can do is to hide it. Please refer to these StackOverflow Q&As: Permanently hide navigation bar on activity; Hide System Bar in Tablets.

How to disable naviagation bar in Android LockScreen App like CM locker and OS8 lock screen

I tried setting systemUIView(View.GONE) and use Immersive Full-Screen Mode. But users can always get the naviagtion bar back by touching the bottom of the screen. The apps i mentioned above are able to hide it without root or setting default launcher.
Okay, I found a solution finally and here is how it's done:
Use SYSTEM_UI_FLAG_IMMERSIVE_STICKY to hide the navigation bar as follow, you may put the code inside onResume of your activity
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
Then, add a system error window using WindowManger and overlay it on top of everything
you can put this unescapable view anywhere you like, but if you want to do it while users locked the screen, add this flag:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
Et voilà
Well I've never achieved this but it seems that you will need to set some other flags to get this kind of view :
When you use the SYSTEM_UI_FLAG_IMMERSIVE flag, it hides the system bars based on what other UI flags you have set (SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_FULLSCREEN, or both). When the user swipes inward in a system bars region, the system bars reappear and remain visible.
Here is a snippet that you can use to set these flags :
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
For more information go check Using Immersive Full-screen Mode from the android developer website.
Hope this help.

Android kiosk mode app - running status bar

I've got a problem with status bar in kiosk mode App.
I want to know how to hide status bar and I know that is it possible to disable it permanently in 4.4.2 Kitkat? But I found nice app -KioWare.
There is cool mode when I grab status bar down, it is running back to the top very quickly. In 0.05 sec. I am not able to click anything. And this is what I'm looking for.
I can't buy this app because it's to expensive and I only need this magic trick with status bar. Anyone can help me ? It should be only few lines of code.
I wrote an article that covers this question, but specifically for Lollipop. I'm not sure if the immersive mode in Android 5 will also apply for 4.4.2, but it's something to try out maybe?
http://www.sureshjoshi.com/mobile/android-kiosk-mode-without-root/
#Override
protected void onResume() {
super.onResume();
hideSystemUI();
}
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}

Overlay status bar and system button bar in full screen mode

I want to write an app with overlay status bar and system button bar like below picture. I tried
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_FULLSCREEN;
but it when status bar and system button bar appear, they come with two black bars. Can anyone help me?
Image
Documentation:
The figure below illustrates the different "immersive mode" states:
Situation 4 - Sticky flag This is the UI you see if you use the IMMERSIVE_STICKY flag, and the user swipes to display the system bars. Semi-transparent
bars temporarily appear and then hide again. The act of swiping
doesn't clear any flags, nor does it trigger your system UI visibility
change listeners, because the transient appearance of the system bars
isn't considered a UI visibility change.
https://developer.android.com/training/system-ui/immersive.html

Categories

Resources