Disable ScreenShot in Android - Xamarin.Forms
Taking ScreenShot in device is the best way to keep record at time where you don't want to write it down or you may want to have a copy of it. Android device gives us an opportunity to capture the screen content in the form of Image.
If you don't want the user to capture the screen content for the purpose of security or for some other reason, you can achieve it in a very easy way.
Lets see how to achieve it using Xamarin.Forms.
You have to write a native code for android and iOS. And yes, we have to struggle for iOS, we will see why and how we can overcome it.
Xamarin.Android:
1) Open the MainActivity.cs file under your projectName.Droid project.
2) In the OnCreate() method, write the below Line just before the LoadApplication(new App()).
- Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
The image for MainActivity.cs is given below:
If you don't want the user to capture the screen content for the purpose of security or for some other reason, you can achieve it in a very easy way.
Lets see how to achieve it using Xamarin.Forms.
You have to write a native code for android and iOS. And yes, we have to struggle for iOS, we will see why and how we can overcome it.
Xamarin.Android:
1) Open the MainActivity.cs file under your projectName.Droid project.
2) In the OnCreate() method, write the below Line just before the LoadApplication(new App()).
- Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
The image for MainActivity.cs is given below:
Please let me know if you have any queries.
Post your comments. If this post helped you please hit the like button.
Thank you.
not works on some mobiles
ReplyDelete