full screen application android

后端 未结 8 775
暖寄归人
暖寄归人 2020-12-06 02:08

i have two questions:

  1. one how can i run my application in full screen
  2. how video players run videos in full screen.

i have tried alot an

8条回答
  •  情话喂你
    2020-12-06 02:12

    I think you cant hide the system bar in android 4.0 > (only in tablets, in phones you should be able to)

    What you can do is to hide the icons and to disable some buttons(everyone except home)

    You can try this:

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);              
    
            }
    

    Also for disabling the buttons:

    This is for back button:

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

    This for the menu:

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

提交回复
热议问题