Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to check the visibility of the status bar?

I have a service that should check periodically visibility of status bar, when some top activity is (or not) in fullscreen mode. Is it possible?

like image 266
deviant Avatar asked Nov 20 '11 10:11

deviant


1 Answers

hello and if you try this code that provides android as good practice

View decorView = getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener
        (new View.OnSystemUiVisibilityChangeListener() {
    @Override
    public void onSystemUiVisibilityChange(int visibility) {
        // Note that system bars will only be "visible" if none of the
        // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
        if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
            // TODO: The system bars are visible. Make any desired
            // adjustments to your UI, such as showing the action bar or
            // other navigational controls.
        } else {
            // TODO: The system bars are NOT visible. Make any desired
            // adjustments to your UI, such as hiding the action bar or
            // other navigational controls.
        }
    }
});

I leave the link of the documentation: https://developer.android.com/training/system-ui/visibility#java

like image 172
Leandro Castillo Borja Avatar answered Oct 23 '22 10:10

Leandro Castillo Borja