Sceneform-android-sdk: How to exit full screen when using ArFragment

Created on 8 Jun 2018  路  3Comments  路  Source: google-ar/sceneform-android-sdk

Hello, i've been trying all sorts of things to not make statusbar hide itself when ArFragment loads, but can't seem to successfully do it by setting/clearing various activity window flags. I even tried OnGlobalLayoutListener for sceneView but still no luck. How can this be achieved

This is how i mainly tried it within global listener, scene OnUpdateListener etc.

activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
activity?.window?.decorView?.systemUiVisibility = SYSTEM_UI_FLAG_VISIBLE

Navigation bar is also hidden, which i'd like to revert, I assume it is the same fullscreen flag problem

question

Most helpful comment

Thanks for the question. Currently there is no way to directly control this via the fragment configuration. A work around is to override the onWindowFocusChanged() methodin a subclass of ArFragment, then you can implement it as needed.

All 3 comments

Thanks for the question. Currently there is no way to directly control this via the fragment configuration. A work around is to override the onWindowFocusChanged() methodin a subclass of ArFragment, then you can implement it as needed.

Ok this resolves the problem (if i don't call the super, just to clarify for others). Thanks for your help!

Hi Clayton.

Please, could you explain a little more on this.

How can I use onWindowsFocusChanges from inside a Fragment?

I usually follow this way when an Activity is used:

@Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        // Get a support ActionBar corresponding to this toolbar
        ActionBar ab = getSupportActionBar();
        ab.setDisplayHomeAsUpEnabled(true);
        //
        if (hasFocus) {
            showSystemUI();
        }
    }

    private void showSystemUI() {
        // Enables regular immersive mode.
        // For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
        // Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        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.
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }

...but I can麓t call getSupportActionBar or getWindow (mut I call it through getActivity?) in the case of a Fragment.

Thanks for your time.

Was this page helpful?
0 / 5 - 0 ratings