0

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 ?

Thanks.

TheDeveloper
  • 1,127
  • 1
  • 18
  • 55
  • screenshots are stored in the camera roll. You can use the Photos SDK to delete them, but it will prompt the user for permission. – Jason Oct 31 '16 at 19:12
  • Can you provide sample code to access / delete screenshots? – TheDeveloper Oct 31 '16 at 19:29
  • You could also try [preventing the screen](https://stackoverflow.com/questions/37960257/is-there-a-way-to-disable-screenshot-in-xamarin-forms) in the first place. – Rokuren Oct 31 '16 at 19:52

1 Answers1

3

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/

Pooja Kamath
  • 1,290
  • 1
  • 10
  • 17