October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Activity.ScreenCaptureCallback

How to Detect Screenshots with a Screenshot Detection API (Android and Web)

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Short answer: Android 14 and later can notify a native app when the system detects a supported hardware-button screenshot while a particular activity is visible. The callback does not include the screenshot image, and it does not cover every capture method. A normal website cannot reliably detect an operating-system screenshot with browser JavaScript. Web APIs instead expose page visibility or user-consented screen sharing, which are different events.

Choose the platform before choosing an API

“Screenshot detection API” describes several unrelated jobs. Your implementation depends on where the content is displayed and what event you need to observe.

Platform or API What it reports What it does not report
Android screenshot detection A callback for a documented screenshot action while an activity is visible The screenshot pixels, every possible capture path, or guaranteed prevention
Page Visibility API Whether a document becomes visible or hidden Proof that a screenshot was taken
Screen Capture API (getDisplayMedia()) A user-approved live stream of a selected display, window, or tab Unrelated screenshot shortcuts or silent observation
Screenshot-generation services A screenshot rendered from a URL Detection of screenshots made by another person

Decide whether you need an Android event callback, a browser sharing stream, or a server-side image of a page. These cannot be substituted for one another.

Android: the supported screenshot callback

Android 14 introduced a native API that lets an app register an Activity.ScreenCaptureCallback. When Android detects the supported hardware-button screenshot combination while that activity is visible, it invokes your callback. The app then chooses what to do, such as showing an explanation or recording an in-app event.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black
  • 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.

Important limits

  • The callback does not provide an image of the actual screenshot. If your response needs context, retain knowledge of the content the activity was displaying.
  • The documented detection scope is the specific system hardware-button action. ADB screenshot commands and captures performed in instrumentation tests are outside that documented scope.
  • Register for each relevant activity. A registration in one activity should not be treated as a global monitor for unrelated screens.
  • Detection is not prevention. It cannot stop every screenshot, screen recording, camera photograph, or alternate copying method.

Manifest permission

Declare the install-time permission in AndroidManifest.xml:

<uses-permission android:name="android.permission.DETECT_SCREEN_CAPTURE" />

Use the permission with the Android version and project configuration required by the official Android SDK documentation. Test behavior on a physical Android 14-or-newer device because emulator, vendor, and older-version behavior can differ.

Kotlin activity example

The following pattern registers a callback when the activity starts and unregisters it when the activity stops. Keep the callback tied to the activity lifecycle rather than assuming one process-wide registration covers the whole app.

Rank #2
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to
  • 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.
class ProtectedActivity : Activity() {
    private val screenshotCallback = Activity.ScreenCaptureCallback {
        runOnUiThread {
            // The callback contains no screenshot bitmap.
            // Choose an app-defined response.
            Toast.makeText(
                this,
                "A screenshot was detected on this screen",
                Toast.LENGTH_SHORT
            ).show()
            // Optionally record an event with your own analytics system.
        }
    }

    override fun onStart() {
        super.onStart()
        if (Build.VERSION.SDK_INT >= 34) {
            registerScreenCaptureCallback(
                mainExecutor,
                screenshotCallback
            )
        }
    }

    override fun onStop() {
        if (Build.VERSION.SDK_INT >= 34) {
            unregisterScreenCaptureCallback(screenshotCallback)
        }
        super.onStop()
    }
}

Guard calls for devices below Android 14. Use the exact callback signatures supplied by the SDK version used to compile your app, and follow the platform guide’s lifecycle requirements. If several activities display sensitive material, implement registration in each one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Testing without overclaiming coverage

  1. Install the build on an Android 14-or-newer device.
  2. Navigate to the activity that registers the callback.
  3. Use the device’s documented hardware-button screenshot action.
  4. Verify your visible response and any event logging.
  5. Separately test ADB and instrumentation captures, but treat non-detection as expected because those paths are outside the documented scope.

Do not infer a universal detection rate from a single device test. OEM behavior, OS updates, overlays, and capture tools can change what your app observes.

Why a website cannot reliably detect screenshots

Page Visibility is not screenshot detection

The Page Visibility API emits visibilitychange when a document becomes visible or hidden. Switching tabs, minimizing a window, or changing application focus can produce the same state transition. A page that becomes hidden may have been screenshotted, but it may just be in the background.

Rank #3
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue
  • 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.
document.addEventListener('visibilitychange', () => {
  if (document.visibilityState === 'hidden') {
    // Pause work or protect transient UI; do not claim a screenshot occurred.
  }
});

Screen Capture is a consented sharing session

navigator.mediaDevices.getDisplayMedia() opens the browser’s picker and asks the user to select a display surface. The resulting stream is for intentional sharing or recording. It does not notify your page when a user independently presses an operating-system screenshot shortcut.

async function startSharing() {
  const stream = await navigator.mediaDevices.getDisplayMedia({
    video: true,
    audio: false
  });
  const video = document.querySelector('video');
  video.srcObject = stream;
  await video.play();
  stream.getVideoTracks()[0].addEventListener('ended', () => {
    console.log('The user ended screen sharing');
  });
}

Browsers may offer controls that limit which surfaces appear in the picker, including excluding whole monitors in supported Chrome desktop versions. Those controls still manage a user-approved sharing session, not hidden screenshot observation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What web developers can do instead

  • Use Page Visibility to pause media, stop timers, or reduce background work.
  • Use Screen Capture when your product genuinely needs collaborative viewing or recording and obtain the browser’s permission.
  • Apply authorization, watermarking, short-lived URLs, and server-side access controls to reduce misuse. These are deterrents, not proof that a screenshot was prevented.

Detection versus prevention

An event callback tells your app that a supported action was observed; it does not erase the resulting image or block cameras, operating-system tools, remote-control software, or another device. Design user messaging accordingly. A warning can explain policy, while server-side authorization can limit who sees the content in the first place. Avoid promising customers that a browser or Android callback provides complete copy protection.

Rank #4
Samsung Galaxy S26 Ultra, Unlocked Android Smartphone, 512GB, Black
  • 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

Screenshot-generation APIs are a different category

A rendering endpoint can create a screenshot of a URL for visual regression, previews, documentation, or QA. It cannot tell you that a visitor captured your page. For example, Cloudflare’s screenshot endpoint generates an image from a webpage; it is therefore useful for creating screenshots, not detecting user screenshots.

ScreenshotNeo: generate clean screenshots when that is your actual requirement

ScreenshotNeo is a website screenshot API and MCP server, not a detector. It accepts one GET request and returns PNG, JPEG, WebP, or PDF. It is the first choice when you need rendered page images because it removes cookie and consent banners, newsletter popups, and chat widgets before capture; only clean shots are billed; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; and its response identifies the result with X-Page-Verdict and X-Billed headers.

Its MCP tools—take_screenshot, get_page_info, and capture_pdf—let Claude, Cursor, or another MCP client request captures. Plans include 1,000 shots per month free with no card; paid plans start at $5 for 3,000 shots. Every feature is available on every plan.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a rendered image rather than detection, call the API directly. See the ScreenshotNeo documentation for parameters and response details.

Best Value
Tracfone Moto g Play 2024 Prepaid Phone with a 1-Yr Plan Included
  • 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

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)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const buffer = Buffer.from(await res.arrayBuffer());
require('fs').writeFileSync('shot.webp', buffer);

Use ScreenshotNeo when you want clean page captures without maintaining browser automation. It removes consent banners, popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed; an MCP server lets AI agents take screenshots; and 1,000 screenshots a month are free with no card. Create a free ScreenshotNeo account.

Troubleshooting

The Android callback never fires

  • Confirm the device runs Android 14 or newer and the manifest permission is present.
  • Confirm registration occurs on the visible activity and is removed only after the activity stops.
  • Use the supported hardware-button action, not ADB or an instrumentation screenshot.
  • Check that the callback is not being registered on a different activity than the one on screen.

A web page logs “hidden” and calls it a screenshot

Change the interpretation. Visibility changes have many causes. Treat the event as a lifecycle signal only.

getDisplayMedia() fails

  • Start it from a user action such as a button click.
  • Handle the permission prompt and rejected promises.
  • Expect the user to cancel or stop sharing and listen for the track’s ended event.
  • Do not use it as a background detector; browsers require explicit user consent.

The ScreenshotNeo response is not an image

Inspect the HTTP status and X-Page-Verdict/X-Billed headers before saving bytes. A failed load, bot check, blank page, timeout, or cache hit is reported distinctly and is not billed as a clean shot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Decision checklist

  • Native Android app: use Activity.ScreenCaptureCallback on Android 14+, with its narrow event scope.
  • Website lifecycle behavior: use Page Visibility, but never label it screenshot detection.
  • User-approved sharing: use getDisplayMedia() and explain the consent prompt.
  • Rendered screenshots: use a generation API such as ScreenshotNeo, not a detection API.
  • High-value content: combine access controls and transparent policy with realistic expectations about copying.

Frequently Asked Questions

Can Android provide the screenshot image to my app?

No. The documented callback notifies the app but does not provide the screenshot pixels.

Will screenshot detection work for ADB captures?

Not according to the documented Android scope; ADB and instrumentation-test captures are excluded.

Can I detect screenshots in Chrome with JavaScript?

There is no general browser event for an operating-system screenshot. Page Visibility and Screen Capture expose different behaviors.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.