Screenshot detection
The platform tells the SDK when a screenshot is taken while your app is in
the foreground, and DeviceShield.screenshots passes it on:
final subscription = DeviceShield.screenshots.listen((_) { // A screenshot was just taken.});
// Later:await subscription.cancel();Platform behaviour
Section titled “Platform behaviour”| Android | iOS | |
|---|---|---|
| Supported | Android 14 (API 34) and later | All supported versions |
| Mechanism | Activity.registerScreenCaptureCallback |
userDidTakeScreenshotNotification |
| Timing | Just after capture | After the screenshot is saved |
Neither platform lets an app prevent a screenshot from here; you’re told after the fact. Use screenshot protection to keep content out of screenshots.
With screenshot protection on, Android still reports the screenshot. The image the user gets is black.
Limitations
Section titled “Limitations”- Below Android 14 the stream never fires, and there’s currently no way to ask whether the running device supports it.
- Screen recordings don’t fire this. See Screen recording.