Android动态设置禁止截屏
private void setWindowSecure(boolean isSecure) {
if (isSecure) {
if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_SECURE) != 0) {
return;
}
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
} else {
if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_SECURE) == 0) {
return;
}
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
}
转自 https://my.oschina.net/kingguary/blog/1610267