Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

341
Vistas
Why does the navigationBars() come back on Fullscreen activity?

I work on Android API 30+, and I want to make a fullscreen app. I disabled the navigationBars() here :

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = ActivitySplashscreenBinding.inflate(getLayoutInflater());
    setContentView(binding.getRoot());
    mContentView = binding.fullscreenContent;
    mContentView.getWindowInsetsController().hide(WindowInsets.Type.navigationBars());

However, when I click anywhere, the navigationBars() come back.

If I do a second click/touch, it disappears again, and this situation is every time.

Any ideas?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

After few hours, I found a solution :

@Override
public void onWindowFocusChanged(boolean hasFocus) {
   super.onWindowFocusChanged(hasFocus);
   if(hasFocus)
   {
       fullSceen(getWindow().getDecorView());
   }
   else {
       try {
           Object wmgInstance = Class.forName("android.view.WindowManagerGlobal").getMethod("getInstance").invoke(null);
           Field viewsField = Class.forName("android.view.WindowManagerGlobal").getDeclaredField("mViews");

           viewsField.setAccessible(true);
           ArrayList<View> views = (ArrayList<View>) viewsField.get(wmgInstance);
           for (View view: views) {
               fullSceen(view);

               view.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
                   @Override
                   public void onSystemUiVisibilityChange(int visibility) {
                       fullSceen(view);
                   }
               });
           }
       } catch (Exception e) {
           e.printStackTrace();
       }
       AppUtils.console(this,TAG, "hasFocus == false");
   }
}
private void fullSceen(View view){
   view.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);
}

Depreciated since Android 30+. For last API, use :

        binding = ActivityBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        mContentView = binding.fullscreenContent;
        mContentView.getWindowInsetsController().setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
        mContentView.getWindowInsetsController().hide(WindowInsets.Type.navigationBars());

Thanks to @Hong Nguyen

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda