Xamarin iOS/Android:如何在应用程序运行时删除屏幕截图 [英] Xamarin iOS/Android: How to delete screenshot when app is running

查看:31
本文介绍了Xamarin iOS/Android:如何在应用程序运行时删除屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Xamarin 表单开发适用于 iOS 和 Android 的移动应用程序.在应用程序中,如果用户在我的应用程序处于活动状态时尝试拍摄,我想删除屏幕截图.Xamarin 只是在 iOS/Androis SDK 上使用 c# 包装器,所以如果它可能与 swift/objective-c/java 一起使用 Xamarin.

I am developing a mobile app for iOS and Android using Xamarin forms. In the application, I want to delete the screenshots if user tries to take when my app is active. Xamarin just uses a c# wrapper over iOS/Androis SDK so if its possible with swift/objective-c/java its possible with Xamarin.

谁能建议如何做到这一点?

Can anyone suggest how this can be done ?

谢谢.

推荐答案

您可以阻止屏幕截图,而不是删除它们.对于 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/

这篇关于Xamarin iOS/Android:如何在应用程序运行时删除屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆