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!!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With