安卓系统工具:显示系统级警报:如何使用这个权限? [英] Android: System Tools: Display System Level Alerts: How to use this Permission?
问题描述
对所用的谷歌Play商店称为画面过滤器,其目的是覆盖一些半透明的黑色整个屏幕的应用程序,以允许在屏幕为比最小亮度调光
为此,它使用了一个名为显示系统级警报。
许可-
在哪里,让我做这件事在我的应用程序的文档?
-
可这系统级警报拦截触摸事件?这是这样我就可以让我的应用程序接管<一href="http://stackoverflow.com/questions/9590851/does-android-support-lock-down-to-a-fully-replaced-interface/9591107#comment12164786_9591107">an安卓是应该留在我们的建设。
我喜欢这种方法,因为它$ P $被关闭之前,它被打开了(这将触发报警),当然,除非有涉及锤子pvents电话。
-
文档的
Manifest.Permission
显示,<一个href="http://developer.android.com/reference/android/Manifest.permission.html#SYSTEM_ALERT_WINDOW"><$c$c>SYSTEM_ALERT_WINDOW$c$c>是您正在寻找的权限。您将宣布在清单此权限
,然后在对话框
或任何其他类型的的窗口
您将设置该标志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 theSYSTEM_ALERT_WINDOW
is the permission you are looking for. You would declare this permission in theManifest
and then in aDialog
or any other kind ofWindow
you would set this flagWindowManager.LayoutParams.TYPE_SYSTEM_ALERT
. So for aDialog
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 aDialog
(as a system level alert) which needs a password to make it go away.
这篇关于安卓系统工具:显示系统级警报:如何使用这个权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!