Flutter:禁用应用程序的屏幕截图 [英] Flutter: disable screenshot capture for app
本文介绍了Flutter:禁用应用程序的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作 Flutter 应用程序,我需要确保用户无法捕获应用程序的屏幕截图(任何屏幕).有没有办法在 Flutter 中实现这一点,还是我需要为 Android 和 IOS 编写本机代码?
I am making a Flutter app and I need to make sure the user is not able to capture screenshot of the app (any screen). Is there any way to achieve this in Flutter or do I need to write native code for both Android and IOS?
推荐答案
- 在 Flutter 项目的嵌入式 android 项目目录中找到您的 MainActivity 类
- 将以下导入添加到您的主活动类:
import android.view.WindowManager.LayoutParams;
- 将以下行添加到 MainActivity 的 onCreate 方法:
getWindow().addFlags(LayoutParams.FLAG_SECURE);
这篇关于Flutter:禁用应用程序的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文