System Overlay Detector

纵饮孤独 提交于 2019-12-31 01:48:34

问题


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.


回答1:


Android View documentation offers clear ways :

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.

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.

Also refer to this sample code.



来源:https://stackoverflow.com/questions/40076758/system-overlay-detector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!