Is there a way to determine if Android app is running full screen?

后端 未结 10 1914
春和景丽
春和景丽 2020-12-31 04:17

i was just wondering if there was a simple way to see if an application running on android is currently in full screen. is there a way to query android to see if you\'re cu

相关标签:
10条回答
  • 2020-12-31 04:38

    You can figure out if your Activity is running fullscreen via getWindow().getFlags().

    However, if by "an application" you are referring to somebody else's application, then the answer is no.

    0 讨论(0)
  • 2020-12-31 04:40

    you may use some thing like this;

    findViewById(android.R.id.content).getHeight();
        getResources().getDisplayMetrics().heightPixels;
    

    and check for equality; hope this helps;

    0 讨论(0)
  • 2020-12-31 04:43

    As of api11 there is now a way to detect that using a View.setOnSystemUiVisibilityChangeListener

    The listener interface documentation notes the following:

    Interface definition for a callback to be invoked when the status bar changes visibility. This reports global changes to the system UI state, not what the application is requesting.

    I don't know if there's a way to do it prior to Honeycomb.

    0 讨论(0)
  • 2020-12-31 04:46

    if you want to Respond to UI visibility changes for all apps including yours, use this code

    View decorView = getWindow().getDecorView();//you can also use findViewById to get the view
    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.
            }
        }
    }); 
    

    source of info

    0 讨论(0)
提交回复
热议问题