How to Hide The System/Navigation Bar in Android Ics

Easy way to hide system bar on Android ICS

HideBar has a kiosk mode especially for this use case.

A free download is available at http://ppareit.github.com/HideBar/.
You can also find it in the market at https://play.google.com/store/apps/details?id=be.ppareit.hidebar.

If you want to incorporate it in your own test/survey application you can always contact the developer (see the links for an email). The code could be explained or an Intent to do the hiding could be provided.

Android ICS hide System bar

I will not talk about the 'why', just about the 'how' :-)

So, about

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

This will not affect tablet devices, which use a system bar rather than a separate navigation
and status bars.

On Tablet, you could try (API Level 14 onward)

myView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);

To detect the event, I think you could use this to catch the event:

myView.setOnSystemUiVisibilityChangeListener(
new OnSystemUiVisibilityChangeListener()
{
public void onSystemUiVisibilityChange(int visibility)
{
if (visibility == View.SYSTEM_UI_FLAG_VISIBLE) {
// TODO whatever you want
}
else {
// TODO what to do in the other case
}
}
}
);

More generally, here is an additional advice from 'Professional Android 4 Application development'

It’s generally good practice to synchronize other changes within your
UI with changes in navigation visibility. For example, you may choose
to hide and display the Action Bar and other navigational controls
based on entering and exiting “full screen mode.” You can do this by
registering an OnSystemUiVisibilityChangeListener to your View —
generally, the View you are using to control the navigation visibility

.

How to Hide System Navigation Bar in Tablets?

In Tablets running Android 4+, it is not possible to hide the System / Navigation Bar.

From documentation (Controls for system UI visibility section) :

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
).

However, you could try to dim the system bar as done sometimes during gaming and video playback.

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.

is it possible to hide the system bar

You can't hide it but you can disable it, except home. For that you can give your application as home category and let the user choose.

<category android:name="android.intent.category.HOME" />

Rest all can be disable.

add this in manifest.

<uses-permission android:name="android.permission.EXPAND_STATUS_BAR"/>

inside onCreate()

this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_home);
View v = findViewById(R.id.home_view);
v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);

where home_view is the parent view of xml file.

 @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return false;
}

public void onWindowFocusChanged(boolean hasFocus)
{
try
{
if(!hasFocus)
{
Object service = getSystemService("statusbar");
Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");
Method collapse = statusbarManager.getMethod("collapse");
collapse .setAccessible(true);
collapse .invoke(service);
}
}
catch(Exception ex)
{
}
}

Is there a way to hide the system bar in Android 3.0? It's an internal device and I'm managing navigation

You cannot hide the system bar on Android 3.0.



Related Topics



Leave a reply



Submit