Hello, I know that we are able to disable the screenshot function for the whole Android app by doing this: this.Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
Now I want to go further by doing that in a certain page, rather than the whole app. Is it possible to do that? Thanks in advance.
Answers
This will only affect the current activity. If you move to another activity you can take screenshots there.
I tested it on my real physical phone and place it in the OnCreate like:
@LandLu thanks for your answer. However, I'm using Xamarin Forms, and can't specify which activity that needs to be modified. If I put that code into MainActivity.cs, then the whole app will be affected.
Forms only has one activity so if you do this configuration in the
MainActivity
all the pages can't be captured.You can subscribe a MessagingCenter in the OnCreate event of the main activity. When the page displays send a signal to notify the activity to disable the screenshot capturing. And enable it when it disappears.
Here is the code: