6

I created a launcher, to use it in an internal application. for some security reasons i would like to hide the system bar (the acces to the parameter an ordrer to the acces to installed application). But i have no idea how to do this. Tablet that will be used are not rooted. Can you help me please?

user2043602
  • 237
  • 2
  • 4
  • 15

5 Answers5

13

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)
             {
             }
     }
PiyushMishra
  • 5,743
  • 6
  • 37
  • 57
8

You can hide the bottom bar I used this code to hide:

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

use this code for android box with keyboard or remote.

kleopatra
  • 51,061
  • 28
  • 99
  • 211
joy
  • 131
  • 1
  • 8
5

Tablet that will be used are not rooted

Then you can't hide it. You can however use SYSTEM_UI_FLAG_HIDE_NAVIGATION to hide it temporary, but it will get visible once the user touches the screen:

There is a limitation: because navigation controls are so important, the least user interaction will cause them to reappear immediately. When this happens, both this flag and SYSTEM_UI_FLAG_FULLSCREEN will be cleared automatically, so that both elements reappear at the same time.

Ahmad
  • 69,608
  • 17
  • 111
  • 137
  • 3
    This is correct. Apps are not permitted to perform actions that could be used as a denial of service attack against the user, and preventing the user from accessing the Home or Recents buttons qualifies. – adamp Feb 10 '13 at 22:40
  • thanks. but in my project, i need to create 2 profil with acces to all application and an other one with limited acces and with some application. their for i need to hid it not temporary but all the time. – user2043602 Feb 11 '13 at 13:28
1

You can hide the navigation bar on Android 4.0 and higher using the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. This snippet hides both the navigation bar and the status bar:

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions

See the following: Hiding the Navigation Bar

dayanruben
  • 1,061
  • 2
  • 12
  • 21
0

Put this in your onCreate() method:

requestWindowFeature(Window.FEATURE_NO_TITLE);

EDIT: Hiding the status bar would require your application be full screen or rooted.

  • thanks; once i use your proposition my application crashs. i dont need to hid the title of the application but to hid the bar with acces to network and parameter or to protect it with a password for security reasons. i cant root the device because the solution will be used with consumer tablet and with an important number so i can't root all devices. – user2043602 Feb 11 '13 at 13:45
  • Sorry that can't be done. As for the code I recommended for you, place it in the onCreate() method and place it above or below (sorry, not at my desktop at the moment) the super on create. –  Feb 11 '13 at 16:09