问题
I have a service that adds some views to the window manager (something like facebook's chat heads). This views stay on top of everything all the time, even when I'm on the camera app. Is it possible to know when some activity (like the camera or a video player) is using full screen so I can hide my views?
Edit:
There's something called View.OnSystemUiVisibilityChangeListener but it requires API 11. My target is 9, but it looks like this is exactly what I need. Any alternative for API 9?
回答1:
Ok, if anyone is interested, I've solved my problem this way: Added a transparent view to the window manager, with 1px width and match_parent height. Then added a global layout listener to this view, and everytime there's a change on the layout, I check the position of this view on screen. If it's Y is 0, then the status bar is not visible, so a full screen app must be running. This works even better than the native View.OnSystemUiVisibilityChangeListener because it seems there are some apps that somehow don't trigger that method (like the new yahoo weather).
来源:https://stackoverflow.com/questions/18551135/receiving-hidden-status-bar-entering-a-full-screen-activity-event-on-a-service