Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
First identify whether Android throws SecurityException at the call site or reports a screenshot failure through the callback. For display capture, use AccessibilityService.takeScreenshot() on API 30 or later and declare android:canTakeScreenshot="true" in the service’s accessibility metadata. If Android reports ERROR_TAKE_SCREENSHOT_SECURE_WINDOW, the target contains protected content; the supported response is to treat it as unavailable, not to bypass the protection.
Start by identifying which screenshot failure you have
The phrase “screenshot SecurityException” does not identify one universal Android failure. A call can throw an exception before screenshot processing starts, while a request that reaches the screenshot API can report success or failure through its callback. Those are different failure channels and call for different investigation.
Record the complete exception message and stack trace, the Android API level, and whether the failing call is takeScreenshot or takeScreenshotOfWindow. Then compare the result with the documented capability and secure-window cases below. The available Android references do not establish that every screenshot failure throws the same exception, so do not assume a fix based on the exception class alone.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Check the API level and the method you call
| Method | Minimum API level | When it applies |
|---|---|---|
takeScreenshot(displayId, executor, callback) |
API 30 | Captures the specified display through the accessibility service. |
takeScreenshotOfWindow(accessibilityWindowId, executor, callback) |
API 34 | Captures a specific accessibility window; useful if accessibility overlay contents are covering the target window. |
These methods are not interchangeable across Android versions. If your app supports versions below the method’s minimum API, guard the call with an API-level check and provide an appropriate alternative for your app’s purpose. Do not call the API 34 window method on an earlier version and expect a runtime capability setting to make it available.
#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.
For the signatures and platform behavior, see the Android AccessibilityService API reference.
Declare the screenshot capability in service metadata
For takeScreenshot, Android requires the accessibility service to declare android:canTakeScreenshot="true" in its accessibility-service metadata. Check the XML resource actually referenced by the service declaration; adding a similarly named setting elsewhere does not establish that the service has this capability.
A typical arrangement has a service declaration in the manifest that points to an XML accessibility configuration. Ensure your own existing resource includes the screenshot capability while retaining the other settings your service needs:
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.
<service
android:name=".MyAccessibilityService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:exported="true">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/my_accessibility_service" />
</service>
In res/xml/my_accessibility_service.xml, set the capability on the accessibility-service element:
<accessibility-service
xmlns:android="http://schemas.android.com/apk/res/android"
android:canTakeScreenshot="true"
android:description="@string/accessibility_service_description"
android:accessibilityEventTypes="typeWindowStateChanged"
android:accessibilityFeedbackType="feedbackGeneric" />
This is an illustrative configuration, not a replacement for the event types, feedback type, description, or other metadata required by your service. The important diagnostic point is that canTakeScreenshot belongs in the accessibility-service XML resource tied to the declared service. Android’s AccessibilityServiceInfo reference documents the service capability metadata.
Confirm the service is enabled and has accessibility access
The service must be enabled by the user and have accessibility access. A correct XML declaration does not by itself mean the service is running or enabled on a device. Verify the service in Android’s Accessibility settings on the affected device, then reproduce the issue after confirming the enabled state.
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.
Do not confuse service access with a screenshot permission toggle or an unrelated hardware setting. First establish that the intended service is installed, enabled, and calling the method from its own service context. If the service is not enabled, resolve that state through the normal user-facing accessibility setup for your app rather than trying to grant access silently.
Handle the callback separately from thrown exceptions
The screenshot API reports a completed request through the callback: success supplies a ScreenshotResult, while failure supplies an error code. Keep the callback path distinct from exception handling around the method invocation. This small Kotlin example shows the structure for display capture on API 30 and later:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
try {
takeScreenshot(
Display.DEFAULT_DISPLAY,
ContextCompat.getMainExecutor(this),
object : AccessibilityService.TakeScreenshotCallback {
override fun onSuccess(result: AccessibilityService.ScreenshotResult) {
// Consume result.hardwareBuffer and result.colorSpace here.
// Release resources when your processing is complete.
}
override fun onFailure(errorCode: Int) {
// Log the numeric code and handle the failure as unavailable.
}
}
)
} catch (e: SecurityException) {
// This is an exception thrown at the call site, not callback failure.
Log.e("Screenshot", "takeScreenshot was rejected", e)
}
}
The example distinguishes the exception path from onFailure; it does not claim that catching the exception repairs a missing capability or makes protected content capturable. In production, implement the screenshot-result handling for your app’s actual use case, and log enough information to diagnose the failure without logging captured personal content.
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
Treat secure-window refusal as intentional
Android defines ERROR_TAKE_SCREENSHOT_SECURE_WINDOW for a window containing secure content, associated with WindowManager.LayoutParams.FLAG_SECURE. This is different from an undeclared service capability or a service that is not enabled: Android is refusing capture because that window is protected. Treat that result as unavailable and do not attempt to work around the protection.
The error constant is documented in the AccessibilityService screenshot error constants. If your callback returns that error, changing service metadata does not turn the protected window into capturable content. If you receive another code, record the exact value and consult the API reference rather than labeling every callback failure a secure-window error.
Recommended Free Tools
Use window-specific capture for an overlay case on API 34+
If the issue is that accessibility overlay contents appear over the target view, and the device runs API 34 or later, consider takeScreenshotOfWindow(accessibilityWindowId, executor, callback) with the relevant accessibility window ID. It captures a selected accessibility window instead of the display-wide view, which can avoid including accessibility overlay contents over the target window.
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
This is a targeted choice for overlay composition, not a general fix for a missing screenshot capability, disabled service, or secure-window refusal. Keep the method’s API 34 availability check, and verify that the ID you pass corresponds to the window you intend to capture.
Follow this diagnostic sequence before changing code elsewhere
- Capture the evidence. Save the exact exception text and complete stack trace, callback error code if one was delivered, Android API level, and method name.
- Check API availability. Confirm display capture is running on API 30+ or window capture on API 34+.
- Inspect the service resource. Confirm the manifest points to the XML configuration you edited and that it contains
android:canTakeScreenshot="true". - Verify user-enabled access. Confirm the accessibility service is installed and enabled on the device where the failure occurs.
- Classify the response channel. Separate a thrown exception from a callback failure; do not treat one as evidence of the other.
- Check for protected content. If the error is
ERROR_TAKE_SCREENSHOT_SECURE_WINDOW, handle it as an intentional refusal. - Consider a window capture only for overlays. On API 34+, use the relevant accessibility window ID if display capture includes overlay contents.
- Escalate with reproducible details. If the exception persists, provide the exact message and stack trace, API level, service manifest and metadata, and the method call.
Common mistakes and fixes
| Symptom or assumption | What to check or do |
|---|---|
| Calling display capture below API 30, or window capture below API 34 | Gate the call on the method’s minimum API level and choose a supported behavior for older versions. |
| Capability is set, but the call still fails | Verify the edited XML is the resource referenced by the service in the manifest, then confirm the service is enabled. |
Assuming every problem will arrive in onFailure |
Wrap the invocation to record a thrown exception separately, and implement the callback failure path as well. |
Callback reports ERROR_TAKE_SCREENSHOT_SECURE_WINDOW |
Treat capture as unavailable for that protected window. Do not recommend bypassing FLAG_SECURE. |
| Display capture includes an accessibility overlay | If API 34+ is available, consider window-specific capture using the correct accessibility window ID. |
| A developer assumes Google Play approval or a declaration enables runtime capture | Check runtime metadata and enabled service access separately from Play policy and declaration requirements. |
| A developer has only the word “SecurityException” | Collect the full stack trace, exact API level, service configuration, and failing method; the exception name alone does not establish the cause. |
Keep Google Play policy separate from runtime capability
Google Play’s AccessibilityService declaration and policy requirements are separate from the runtime screenshot capability. A policy declaration is not a substitute for android:canTakeScreenshot="true", and the metadata setting does not itself settle whether an app complies with Play requirements. Review Google Play’s AccessibilityService API policy guidance for the distribution-policy side of the question.
Or skip the browser setup
ScreenshotNeo is a website screenshot API, not an Android AccessibilityService and not a way to capture a FLAG_SECURE window. It is relevant if your separate task is to capture a public web page from a server or tool instead of running a browser yourself. Its clean-shot flow accepts consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. It also provides an MCP server with screenshot, page-info, and PDF tools for AI agents.
For a web page, the one-call cURL example is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Free includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. The same features are available on every plan. Learn about ScreenshotNeo, or sign up for 1,000 free screenshots a month with no card.
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.

