The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To keep an Android activity’s content out of screenshots, set WindowManager.LayoutParams.FLAG_SECURE on the window that displays the sensitive content. The flag is window-scoped: it is not a device-wide switch, and it should not be presented as a guarantee against every possible capture technique.
Set FLAG_SECURE on the sensitive activity
Apply the flag to the activity window before displaying information that must not appear in screenshots. Android’s official guidance uses the same window-level flag for preventing the activity from appearing in screenshots and on non-secure displays.
Java
activity.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE
);
This is the Java example published in Android’s screenshot-detection guidance. In an activity class, activity is normally the current activity instance.
Free tools Windows power users keep installed
One-click scans. No signup required.
Kotlin
activity.getWindow().setFlags(
LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE
)
Use the equivalent Kotlin call in the activity that owns the private screen. Because the protection belongs to a window, apply it to every relevant activity rather than assuming that setting it on one screen changes all of your app’s windows.
#1 Best Overall
- YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
- LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
- MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
- NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
- BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.
What the flag changes
A flagged window is treated as secure. Its app-rendered content is excluded from screenshots and from non-secure displays such as some casting, projector or external-display paths. Android’s Display API reference describes this behavior in terms of secure surfaces and identifies FLAG_SECURE as the window flag used to create one.
Prevention and detection are different features
Decide first whether your requirement is to suppress pixels or to react when a supported screenshot action occurs. They solve different problems and can be used together, but detection does not replace prevention.
Use FLAG_SECURE when content must not be exposed
The flag is the documented mechanism for excluding the activity’s content from screenshots and non-secure displays. It does not send an image to your app and it does not provide a post-capture event. If the requirement is “do not let this activity appear in a screenshot,” start with the window flag.
Use Android 14 screenshot detection when you need a response
Android 14 adds Activity.ScreenCaptureCallback. This callback notifies an app when Android detects a supported screenshot action; it does not block the screenshot and does not provide the captured image. The API is therefore appropriate for an in-context response such as showing an explanation, recording an event for your own workflow, or asking the user to remove sensitive information before continuing.
The detection API has three operational requirements:
Rank #2
- Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
- DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
- CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
- PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
- BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.
- Declare the install-time permission
android.permission.DETECT_SCREEN_CAPTURE. - Register the callback for each relevant activity while that activity is started.
- Unregister it when the activity stops.
Android documents a specific capture-method boundary: the API detects screenshots made by a supported combination of hardware button presses, but it does not detect screenshots produced by ADB screenshot commands or instrumentation tests that capture screen contents. Treat a missing callback as “this capture path was not covered,” not as proof that no pixels were copied.
Scope and limitations you should design around
It is window-level, not global
FLAG_SECURE applies to the window on which you set it. If a user moves from a protected activity to an unprotected activity, the latter follows its own window configuration. For apps with several sensitive areas, make the decision per activity and document which screens are intentionally protected.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
It also affects non-secure displays
The same setting that suppresses screenshots can prevent the window from being shown on a non-secure external display. That side effect is useful for protecting credentials or personal records during casting, but it can surprise users who expect to present every screen on a projector. Explain the behavior in your product’s privacy or presentation guidance.
Do not promise complete protection from every capture path
Android’s security documentation warns that this mechanism is not reliable for preventing overlay attacks. It also states that, for Android 11 (API 30) and lower, FLAG_SECURE is able to help “around 70% of the devices reliably.” That is Android’s qualified statement for that older platform range, not a current all-device success rate and not a guarantee for every recording, mirroring or vendor-specific path. The official guidance does not establish identical behavior for every screen-recording implementation, so describe your policy as screenshot and non-secure-display protection rather than universal capture prevention.
Consider user control where screenshots are legitimate
Android recommends considering an app setting that lets users toggle the flag. A banking or identity screen may need protection by default, while a support, accessibility or documentation workflow may legitimately require screenshots. If you offer a toggle, make the current state visible and apply the change to the correct activity window; do not imply that a detection callback can substitute for the user’s choice.
Rank #3
- YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
- LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
- MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
- NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
- BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.
Practical implementation patterns
Protect only the private workflow
Put the flag on activities that display secrets, payment information, health data, private messages or other content that should not leave the app. Leave ordinary public screens unprotected when users need to share them. This keeps the privacy boundary understandable and avoids disabling legitimate documentation or support screenshots across the whole app.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesApply protection before sensitive content is shown
Set the flag as part of the protected activity’s setup, before rendering the private state. If the screen can transition between public and private modes, define which window state applies during each transition and test the hand-off on the Android versions and device families you support.
Separate response logic from the security boundary
If you also register ScreenCaptureCallback, keep the callback’s work separate from the code that sets FLAG_SECURE. The callback is a notification channel; it is not evidence that the secure flag failed, and it does not return a bitmap you can inspect.
Testing checklist
- Install a build on each Android version and device family in your support matrix.
- Open the activity with the flag enabled and use the device’s normal screenshot gesture.
- Verify that the captured result does not contain the protected activity’s rendered content.
- Repeat while the app is being cast or shown on an external display, because non-secure-display behavior is part of the same protection.
- If you use Android 14 detection, test the supported hardware-button screenshot path and verify registration while the activity is started and unregistration when it stops.
- Run your ADB and instrumentation screenshot tests separately. Android documents that those test captures are not reported by
ScreenCaptureCallback, so a test harness must not use callback delivery as its pass/fail signal. - Test the user-facing toggle, including relaunching the protected activity and moving between protected and unprotected screens.
Troubleshooting
The screenshot still shows private content
- The flag is on a different window. Confirm that the activity displaying the private pixels is the one whose window receives
FLAG_SECURE. - The sensitive screen is a separate activity. Apply the flag to that activity as well; a setting on a previous activity does not make another activity secure.
- You are testing a capture path with different guarantees. Android’s documentation qualifies the behavior by device and capture mechanism. Test the exact Android versions, OEM builds and external-display paths you intend to support.
- An overlay is involved. Android warns that
FLAG_SECUREis not a reliable defense against overlay attacks. Treat overlay protection as a separate security problem.
The callback never fires
- Check that the app has declared
android.permission.DETECT_SCREEN_CAPTURE. - Confirm that the callback is registered while the target activity is started and removed when it stops.
- Use a supported hardware-button screenshot action. ADB screenshot commands and instrumentation captures are explicitly outside the documented detection coverage.
- Do not expect an image in the callback. The API reports an event; it does not deliver the screenshot pixels.
Casting or presentation shows a blank or missing screen
That can be the intended result of a secure window on a non-secure display. Decide whether the activity should be protected during presentation and expose a clearly explained setting if your users need to switch modes.
Reliability, performance and maintenance considerations
The prevention mechanism is a window flag rather than a network service, so there is no API request, quota or per-capture charge to budget for it. Its practical reliability depends on the Android release, device implementation and capture path. Keep the flag decision close to the activity that owns the data, test it as part of release validation, and avoid describing the result as protection against every form of recording.
Rank #4
- PRIVACY DISPLAY: Automatically hide your screen from those beside you. The built-in privacy display can be preset¹ to turn on when receiving notifications, typing passwords, or using specific apps
- TYPE IT IN. TRANSFORM IT FAST: Enhance any shot in seconds on your smartphone by using Photo Assist² with Galaxy AI.³ Add objects, restore details, or apply new styles by simply typing or tapping
- NIGHTS, CAPTURED CLEARLY: From gigs to city lights, record and capture moments after dark with clarity using Nightography so your photos and videos stay crisp and clear on your Samsung Galaxy
- MAKE IT. EDIT IT. SHARE IT: Turn everyday moments into something personal with creative tools built right into your mobile phone, whether it’s a special contact photo, custom wallpaper, an invitation or more⁴
- HELP THAT KEEPS UP: Stay in the moment while Now Nudge with Galaxy AI helps you respond faster and stay organized with smart suggestions⁵ that appear exactly when you need them on your phone
Detection has lifecycle and permission overhead but remains a separate concern from pixel suppression. Register only for activities where a response is meaningful, remove the callback when the activity stops, and make the response proportionate: a notification or audit event should not be mistaken for a way to recover a screenshot or undo an exposure.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If your separate task is generating clean screenshots of websites for documentation, visual tests or an AI workflow, ScreenshotNeo is a website screenshot API and MCP server. It is not an Android privacy control and cannot make an app window secure; it automates website capture instead.
One GET request returns a PNG, JPEG, WebP or PDF. The API accepts the consent banner before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and each response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info and capture_pdf tools to Claude, Cursor and other MCP clients.
See the ScreenshotNeo documentation for all parameters. The following calls are complete examples:
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Every feature is included on every plan. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots, and yearly billing provides two months free. If you need website captures without configuring a browser, sign up for the free ScreenshotNeo plan.
FAQ
Should every activity in an app use the flag?
No. Apply it to windows that display content requiring screenshot exclusion. Selective protection preserves legitimate sharing on ordinary screens and makes the privacy boundary easier to explain.
Best Value
- Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Activating is easy, just 3 steps.
- ACTIVATION Promotion: Includes 1500 min, 1500 texts & 1500 MB Data + add more as you need it
- CAMERA SYSTEM: 50MP Quad Pixel camera. Capture sharper, more vibrant photos day or night with 4x the light sensitivity.
- PERFORMANCE: Blazing-fast Qualcomm performance. Get the speed you need for great entertainment with a Snapdragon 680 processor and 4GB of RAM.
- 64GB built-in storage. Get plenty of room for photos, movies, songs, and apps. Made for US
Can a callback tell me which part of the screen was copied?
No. Android’s screenshot-detection callback is an event notification and does not provide the captured image or a pixel-level description.
Is website screenshot automation a replacement for Android secure windows?
No. ScreenshotNeo captures web pages through its API. Android apps still need FLAG_SECURE on the relevant activity window when their own rendered content must be excluded.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallFrequently Asked Questions
Should every activity in an app use the flag?
No. Apply it to windows that display content requiring screenshot exclusion. Selective protection preserves legitimate sharing on ordinary screens and makes the privacy boundary easier to explain.
Can a callback tell me which part of the screen was copied?
No. Android’s screenshot-detection callback is an event notification and does not provide the captured image or a pixel-level description.
Is website screenshot automation a replacement for Android secure windows?
No. ScreenshotNeo captures web pages through its API. Android apps still need FLAG_SECURE on the relevant activity window when their own rendered content must be excluded.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

