@Override public void onAttachedToWindow() { super.onAttachedToWindow(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); View view = getWindow().getDecorView().getRootView(); view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); }In this example, we are using `onAttachedToWindow` to hide the status bar and navigation bar. When the activity is attached to a window, we get the root view of the window and set the system UI visibility to full screen, which will hide the status bar and navigation bar. Package Library: `android.app`