Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to detect when any application is in full screen in android?

Tags:

android

view

I would like to know if there is some sort of way using maybe views or something to have a background service detect if the foreground app is in full screen or not. meaning the status bar is hidden or not hidden.

I was thinking maybe using constant strings to detect if a view is shown or not? But im not sure exactly. Root is an option if needed.

Thanks guys!!

like image 983
Seth Avatar asked Dec 15 '22 07:12

Seth


1 Answers

How about using a broadcast receiver or something like that. That would be ideal, however there is no such broadcast for a full screen request.

Here is what I did do however.

I created an invisible overlay, this invisible overlay is 0 x 0 in size :)

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

This returns the int array with the values of the coordinates in x and y. I then test these coordinates (only really focusing on the y value) if it equals 0, then the current viewable activity is in full screen, (because it is at the highest most area on the screen) if the status bar is showing, then the view will return with (50 pixels on my device) meaning the view is 50 pixels from the top of the screens edge.

I place all this in a service which has a timer and when the timer expires, it gets the location, runs the tests, and does what I need to do. The timer is then cancelled when the screen shuts off. Upon screen on, timer is restarted.

I checked how much CPU it uses, and it says 0.0% in System Tuner.

like image 52
Seth Avatar answered Mar 09 '23 01:03

Seth