- Prevent capture screen by setFlag secure
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
- If you want to remove flag secure
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
You can't prevent screen capture on iOS.
I have suggested 2 methods
- After the user capture screen (UIApplicationUserDidTakeScreenshot), send the capture event to the server or display a warning message.
- Try ScreenShieldKit (https://screenshieldkit.com). You can read more from this article. https://medium.com/nomtek/screenshot-preventing-on-mobile-apps-9e62f51643e9
- SetFlag secure already hide preview screenshot
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
- Overlay screen by added 2 two into appDelegate.m
- (void)applicationWillResignActive:(UIApplication *)application {
// fill screen with our own colour
UIView *colourView = [[UIView alloc]initWithFrame:self.window.frame];
colourView.backgroundColor = [UIColor whiteColor];
colourView.tag = 1234;
colourView.alpha = 0;
[self.window addSubview:colourView];
[self.window bringSubviewToFront:colourView];
// fade in the view
[UIView animateWithDuration:0.5 animations:^{
colourView.alpha = 1;
}];
}
- (void)applicationDidBecomeActive:(UIApplication \*)application {
// grab a reference to our coloured view
UIView \*colourView = [self.window viewWithTag:1234];
// fade away colour view from main view
[UIView animateWithDuration:0.5 animations:^{
colourView.alpha = 0;
} completion:^(BOOL finished) {
// remove when finished fading
[colourView removeFromSuperview];
}];
}