Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
304 views
in Technique[技术] by (71.8m points)

android - Receiving hidden status bar/entering a full screen activity event on a Service

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...