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

后端 未结 10 1913
春和景丽
春和景丽 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:21

    Following the info of Sigwann, here my code....

    public boolean isFullScreen() {
        int flg = getWindow().getAttributes().flags;
        boolean flag = false;       
        if ((flg & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
            flag = true;
        }
        return flag;
    }
    

    Simple, but works!

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

    Just to complete on Sigwann answer:

    boolean fullScreen = (getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0;
    boolean forceNotFullScreen = (getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN) != 0;
    boolean actionbarVisible = getActionBar().isShowing();
    
    0 讨论(0)
  • 2020-12-31 04:23

    is there a way to query android to see if you're currently in full screen mode or something like that?

    You can get if your app is running in full screen;:

    boolean isFullScreen = (getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0;
    

    i was just wondering if there was a simple way to see if an application running on android

    if you are tryin to get if an application is running in full screen that´s not possible programatically only visually.

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

    There is a nice hack, using the absolute position of a View on screen. Just check the position of any top left view of your layout (can be invisible), if it's on position 0,0. Like this:

    /**
     * Check if fullscreen is activated by a position of a top left View
     * @param topLeftView View which position will be compared with 0,0
     * @return
     */
    public static boolean isFullscreen(View topLeftView) {
        int location[] = new int[2];
        topLeftView.getLocationOnScreen(location);
        return location[0] == 0 && location[1] == 0;
    }
    
    0 讨论(0)
  • 2020-12-31 04:31

    I guess Commonsware wanted to say getWindow().getAttributes() and not getWindow().getFlags(); since getFlags does not exist as far as I know. At least it is not in doc.

    you need to read getWindow().getAttributes().flags, which is an int.

    WindowManager.LayoutParams lp = getWindow().getAttributes();
    int i = lp.flags;
    

    FLAG_FULLSCREEN = 1024 according to android documentation. so your flag is the 11th bite of lp.flags

    if this bite = 1, full screen is activated.

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

    Activity.hasWindowFocus() tells you if your own activity is visible to the user. But, as CommonsWare notes, it's much harder to tell if another activity is on the top of the stack. You can try querying the ActivityManager (e.g, ActivityManager.getProcessTasks() ), but its methods don't provide an exact answer for your question.

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