系统覆盖检测器 [英] System Overlay Detector
问题描述
是否可以在自己的应用程序中检测当前是否存在屏幕覆盖图?例如,我在设置中看到它们可以检测到它:
Is there a way to detect within my own app that a Screen Overlay is currently present? For example, I see in the settings that they detect it:
我想知道是否可以在自己的应用程序中自行检测它.
I would like to know if there is a way to detect it myself within my own app.
推荐答案
Android 查看文档提供了明确的方法:
Android View documentation offers clear ways :
要启用触摸过滤,请调用setFilterTouchesWhenObscured(boolean)或将android:filterTouchesWhenObscured布局属性设置为true.启用后,框架将丢弃收到的触摸每当视图的窗口被另一个可见窗口遮挡时.作为一个结果,无论何时举杯,对话或另一个窗口出现在视图窗口的上方.
To enable touch filtering, call setFilterTouchesWhenObscured(boolean) or set the android:filterTouchesWhenObscured layout attribute to true. When enabled, the framework will discard touches that are received whenever the view's window is obscured by another visible window. As a result, the view will not receive touches whenever a toast, dialog or other window appears above the view's window.
要对安全性进行更细粒度的控制,请考虑覆盖onFilterTouchEventForSecurity(MotionEvent)方法来实现自己的安全政策.另请参见FLAG_WINDOW_IS_OBSCURED.
For more fine-grained control over security, consider overriding the onFilterTouchEventForSecurity(MotionEvent) method to implement your own security policy. See also FLAG_WINDOW_IS_OBSCURED.
也请参考示例代码.
这篇关于系统覆盖检测器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!