对所用的谷歌Play商店称为画面过滤器,其目的是覆盖一些半透明的黑色整个屏幕的应用程序,以允许在屏幕为比最小亮度调光
为此,它使用了一个名为显示系统级警报。
许可在哪里,让我做这件事在我的应用程序的文档?
可这系统级警报拦截触摸事件?这是这样我就可以让我的应用程序接管an安卓是应该留在我们的建设。
我喜欢这种方法,因为它$ P $被关闭之前,它被打开了(这将触发报警),当然,除非有涉及锤子pvents电话。
解决方案文档的 Manifest.Permission
显示,SYSTEM_ALERT_WINDOW是您正在寻找的权限。您将宣布在清单此权限
,然后在对话框
或任何其他类型的的窗口
您将设置该标志 WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
。因此,对于一个对话框
它是这样的:
dialog.getWindow()的setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
是的,这将是能够拦截触摸事件。系统警报,就像一个低电量警告,总是在所有其他应用程序顶开,所以无论窗口
你弹出将重点等。基于你想做什么这一点,我想你可以这样做:弹出对话框
(作为一个系统级警报),它需要密码才能使它走了。
There is an app on the Google "Play Store" called "Screen Filter", which is designed to cover the entire screen with some translucent black, to allow the screen to be dimmer than the minimum brightness.
It does this using a permission called "Display System-Level Alerts".
Where is the documentation that allows me to do this in my app?
Can this "system-level alert" intercept touch events? This is so I can get my app to take over an Android that is supposed to stay in our building.
I like this approach because it prevents the phone from being turned off before it is turned over (which would trigger an alarm), unless of course there is a hammer involved.
解决方案Docs for Manifest.Permission
show that the SYSTEM_ALERT_WINDOW
is the permission you are looking for. You would declare this permission in the Manifest
and then in a Dialog
or any other kind of Window
you would set this flag WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
. So for a Dialog
it would look like this:
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
Yes, it will be able to intercept touch events. System alerts, like a low battery warning, always open on top of all other applications, so whatever Window
you pop up will take focus, etc. Based on what you want to do with this, I'd imagine you could do something like: pop up a Dialog
(as a system level alert) which needs a password to make it go away.
相关推荐
最新文章