is it possible to hide the system bar

前端 未结 5 1675
情歌与酒
情歌与酒 2020-11-28 10:13

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

5条回答
  •  被撕碎了的回忆
    2020-11-28 10:37

    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.

    
    

    Rest all can be disable.

    add this in manifest.

    
    

    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)
                 {
                 }
         }
    

提交回复
热议问题