How to use setScreenCaptureDisabled xamarin

1.2k Views Asked by At

Please don't mark question as duplicate.cuz FLAG_SECURE don't works for me.
As here someone had recommended to use setScreenCaptureDisabled,
But he didn't added any example and also I use xamarin.
So how do I use setScreenCaptureDisabled for disabling screen recording in xamarin ?
I need working code example for xamarin c#.

2

There are 2 best solutions below

3
Cheesebaron On BEST ANSWER

This is not possible in Android. You cannot prevent screen capture on a device that is not managed through a MDM provider. There is no DRM solution available to prevent screen capture for consumer Apps. The idea is that you are supposed to provide tools and features to your users, not prevent them from doing something.

The only thing you can do is to set the FLAG_SECURE on the window to prevent it to show up when screen sharing or in screenshots.

This really has nothing to do with Xamarin, but rather, simply how Android works.

1
AudioBubble On

You can disable screenshots adding this line on MainActivity.cs:

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