应用程序是否有办法:
我知道Android M及以上版本能够在权限页面中检测到屏幕叠加,并在检测到屏幕叠加时拒绝权限更改,但开发人员是否能够在应用层中实现相同的功能?
答案 0 :(得分:0)
您可以通过在用户触摸您的MotionEvent.FLAG_WINDOW_IS_OBSCURED
之一时检查View
标志来检测覆盖。
final View.OnTouchListener filterTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// Filter obscured touches by consuming them.
if ((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0) {
if (event.getAction() == MotionEvent.ACTION_UP) {
Toast.makeText(v.getContext(), "Overlay detected", Toast.LENGTH_SHORT).show();
}
return true;
}
return false;
}
};
yourButton.setOnTouchListener(filterTouchListener);
但是,我认为无法检测出哪个应用拥有重叠广告。