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);
- Locate your MainActivity class inside the embedded android project dir in your Flutter Project
- Add the following import to your main activity class:
import android.view.WindowManager.LayoutParams;
- Add the following line to your MainActivity's onCreate method:
getWindow().addFlags(LayoutParams.FLAG_SECURE);
这篇关于Flutter:禁用应用程序的屏幕截图捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文