首页 > 解决方案 > 无法阻止 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 上运行它。

更新:

它间歇性地发生。有时它会阻止有时它允许屏幕截图。

标签: androidreact-native

解决方案


推荐阅读