android - 无法阻止 android apk (release) 中的屏幕截图
问题描述
我可以通过设置 FLAG_SECURE 来防止屏幕截图。
但是,FLAG_SECURE 在将其构建到 APK 并运行后不会阻止屏幕截图。
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "MyAppName";
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
}
}
知道为什么吗?我在同一台设备三星 Android 7 上运行它。
更新:
它间歇性地发生。有时它会阻止有时它允许屏幕截图。
解决方案
推荐阅读
- django - 如何减少 Django ORM 中的数据库提示?
- python - 无法在 Python 中定位元素 - Selenium
- sql - 使用 (+) 在两个表之间进行左连接
- r - 在条件下使用默认参数调用函数
- php - 使用 JWT 身份验证包时 authentication_listener 不起作用
- java - Intellij 中的 Tesseract 无法读取 pdf,因为“gsdll64”库无法加载
- r - Worldclim:R中的getData()(纬度/经度坐标):utils :: unzip(zipfile,exdir = dirname(zipfile))中的错误:'exdir'不存在
- windows - 在运行作业时将控制台的输出消息分配给变量
- arrays - 如何在 React 的不同页面中传递数组值?
- python - 熊猫奇怪的平等行为