问题
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