Is it possible to detect when an application is in full screen mode in android?

I would like to know if there is some way, perhaps using views or something, to discover the background service if the foreground application is in full screen mode or not. this means that the status bar is hidden or not hidden.

I was thinking maybe using constant lines to determine if the view is displayed or not? But I'm definitely not sure. Root is an option if necessary.

Thanks guys!

+4
source share
3 answers

How to use a broadcast receiver or something like that. This would be ideal, but there is no such broadcast for a full-screen request.

Here is what I did, however.

I created an invisible overlay, this invisible overlay has a size of 0 x 0 :)

Then I use View.getLocationOnScreen(int[]);

Returns an int array with x and y coordinates. Then I test these coordinates (only really focusing on the y value), if it is 0, then the current visible activity is in full screen mode (since it is on the highest area on the screen), if the status bar is displayed, then the view will return with (50 pixels on my device), which means the view is 50 pixels from the top of the edge of the screen.

I put all this into a service that has a timer, and after the timer expires, it gets a place, runs the tests and does what I need to do. Then the timer is canceled when the screen turns off. When the timer starts, the timer restarts.

I checked how much processor it uses and it says 0.0% in the system tuner.

+10
source

Have you tried getWindow().getAttributes().flags ?

 public static boolean fullScreen = (getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; public static boolean forceNotFullScreen = (getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN) != 0; public static boolean actionbarVisible = getActionBar().isShowing(); 

Link:

 if( MyActivity.fullScreen){ // full screen } else{ // not full screen } 
+1
source

I like Seth's idea, so I made a code snippet:

 /** * 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
source

Source: https://habr.com/ru/post/1495243/


All Articles