且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Xamarin iOS/Android:如何在应用程序运行时删除屏幕截图

更新时间:2022-06-13 05:48:01

您可以阻止屏幕截图,而不是删除它们.对于 Xamarin Android,您可以在 OnCreate 方法中设置安全标志.

Instead of deleting screenshots, you can prevent them. For Xamarin Android you can set the secure flags in the OnCreate method.

 protected override void OnCreate(Bundle bundle)
 {
    base.OnCreate(bundle);
    this.Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
 }

显示标志:表示显示器具有安全视频输出并支持合成安全表面.

Display flag: Indicates that the display has a secure video output and supports compositing secure surfaces.

安全表面用于防止应用程序渲染到这些表面中的内容出现在屏幕截图中或在非安全显示器上被查看.

Secure surfaces are used to prevent content rendered into those surfaces by applications from appearing in screenshots or from being viewed on non-secure displays.

https://developer.xamarin.com/api/field/Android.Views.Display.FlagSecure/