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.
source share