是否有可能在任何程序是全屏android系统中检测到? [英] is it possible to detect when any application is in full screen in android?

查看:89
本文介绍了是否有可能在任何程序是全屏android系统中检测到?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有某种形式的使用,也许观点或东西有一个后台服务的方式检测是否前台应用程序是在全屏或没有。这意味着状态栏隐藏或不隐藏。

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.

谢谢你们!!

推荐答案

AHA:D所以我有一个想法..震撼吧?的xD笑

AHA :D So i had an idea.. shocking right? xD lol

总之,我想用说广播接收器或类似的东西。那么,这将是理想的,但是有一个完整的画面要求没有这样的广播。

Anyhow, i was thinking of using say a broadcast receiver or something like that. Well, that would be ideal, however there is no such broadcast for a full screen request.

下面是我做的不过做的。

Here is what i did do however.

我创建了一个无形的叠加,这种无形的覆盖是0 X 0大小:)

I created an invisible overlay, this invisible overlay is 0 x 0 in size :)

I then use View.getLocationOnScreen(int[]);

这将返回在X和Y坐标值的int数组。然后,我测试这些坐标(唯一真正专注于y值),如果它等于0,则当前可见的活动是在全屏幕,(因为它是在屏幕上最高的大部分地区)如果显示状态栏,然后该视图将与(50像素的设备上),这意味着该视图是从屏幕边缘的前50个像素返回。

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.

我查了多少CPU采用,它说,在系统调谐器0.0%。所以我很喜欢这种方法:):)

I checked how much CPU it uses, and it says 0.0% in System Tuner. So i am liking this method :) :)

希望其他人可以使用这个或相同的方法的东西!

Hope others can use this or the same approach for something!

这篇关于是否有可能在任何程序是全屏android系统中检测到?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆