有没有办法检查状态栏的可见性?
我有一项服务,当某些顶级活动处于(或不)处于全屏模式时,应该定期检查状态栏的可见性。 是否可以?
I have a service that should check periodically visibility of status bar, when some top activity is (or not) in fullscreen mode.
Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最后我发现了如何检查状态栏是否可见。它是某种黑客,但它对我有用。我在我的服务中创建了该方法:
其中 widthS 和 heightS 我们的全局屏幕尺寸;
在这里,我只是将不可见的辅助窗口高度与屏幕高度进行比较,并决定状态栏是否可见。并且不要忘记在服务的 onDestroy 中删除 helperWnd 。
Finally I have discovered how to check if statusbar is visible or not. Its some kind of hack, but it works for me. I created that method in my Service:
where widthS and heightS our global screen size;
Here I just compared invisible helper window height to screen height and make decision if status bar is visible. And do not forget to remove helperWnd in onDestroy of your Service.
你好,如果你尝试这个提供 android 良好实践的代码,
我会留下文档的链接: https://developer.android.com/training/system-ui/visibility#java
hello and if you try this code that provides android as good practice
I leave the link of the documentation: https://developer.android.com/training/system-ui/visibility#java
并不真地。如果您的 Activity 位于前台,则您的 Activity 可以告诉服务它是否使用隐藏状态栏的主题。不过,您无法独立于服务来确定这一点,更不用说对于第三方活动而不是您自己的活动了。
Not really. If it is your activity in the foreground, your activity could tell the service if it is using a theme that hides the status bar. You have no way of determining this independently from the service though, let alone for third-party activities rather than your own.