# Why is my AI agent’s Android screenshot black?

Password managers, 2FA, banking apps and private browsers set FLAG_SECURE, so screenshots come out black or empty. Seven apps that did it in our test, the 409 screen_protected answer, and how the agent keeps working with observe.

By [Mustafa Yenler](https://mobilebox.dev/about?via=md#mustafa) [LinkedIn](https://www.linkedin.com/in/mustafa-yenler) Updated 23 November 2026

Engineering4 min read

In this article

Usually because the app sets FLAG_SECURE, which tells Android to keep its screen out of screenshots and screen recordings: password managers, 2FA apps, banking apps and private browsers do it. On Mobilebox, which runs cloud Android phones for AI agents at $0.01 a minute, such a screenshot answers 409 `screen_protected` and names the app, and `observe` still reads the screen as text, so the agent keeps working.

## What FLAG_SECURE does

An app sets [`FLAG_SECURE`](https://developer.android.com/reference/android/view/WindowManager.LayoutParams#FLAG_SECURE) on a window to say its content is private. Android then keeps that window out of screenshots and off non-secure displays, so screen recordings and screen sharing show it black too. On a phone in your hand, a screenshot of such an app comes out black or is refused with a message. With `adb exec-out screencap -p` on your own emulator, you get an empty file or a black frame.

It is the app’s decision, not a broken tool. An agent should not try to get around it, and Mobilebox doesn’t: the point is to tell the agent at once, so it doesn’t send an empty image to its model or report a black screen as a bug in your app.

## Apps that did it in our test

Our [app compatibility run](https://mobilebox.dev/apps?via=md) on production on November 22, 2026 installed apps from F-Droid and their makers' own downloads. Seven of them blocked the screenshot on the screen they opened to:

| App | Kind |
| --- | --- |
| Bitwarden | Password manager |
| KeePassDX | Password manager |
| Aegis | 2FA codes |
| Proton Mail | Email |
| SimpleX Chat | Messenger |
| Briar | Messenger |
| Tor Browser | Private browser |

Before the fix that day, our screenshot call answered those with 200 and 0 bytes: an image that wasn’t one. Now it answers like this, measured on production with Aegis 3.4.3:

```
GET /v1/phones/{id}/screenshot on the home screen  → 200, image/png, 1,356,910 bytes
Aegis open, GET /v1/phones/{id}/screenshot          → 409
  {"code":"screen_protected",
   "message":"com.beemdevelopment.aegis blocks screenshots (FLAG_SECURE), so this screen can't be captured.",
   "next":"Read it with observe: …"}
GET /v1/phones/{id}/observe                         → app: com.beemdevelopment.aegis, 6 elements,
                                                      "Welcome", "Aegis is a free, secure and open source 2FA app", …
```

Over MCP the `screenshot` tool returns the same code and message as its error, so the agent reads why there is no image.

## What to do

1. **Read the screen with `observe`.** FLAG_SECURE covers pixels, not the accessibility tree: the elements, their text and their refs come back as usual, and `act` taps and types on them. For most agent tasks the text is the better evidence anyway, as [screenshot or accessibility tree](https://mobilebox.dev/blog/screenshot-vs-accessibility-tree?via=md) explains.

2. **Handle 409 `screen_protected` in your code.** It is not retryable: the same screen gives the same answer. Fall back to observe, and take the screenshot again once the agent has left the protected screen.

3. **Testing your own app? Set the flag in release builds only.** A debug build without it gives your agent screenshots and recordings; the release build keeps it.

```
if (!BuildConfig.DEBUG) {
    window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
}
```

1. **Need a picture for a person?** The [live view](https://mobilebox.dev/live-view?via=md) shows a protected app black too. Screenshot the screens before and after it, and keep the observe text of the protected screen as the evidence.

## Other reasons a screenshot is black or empty

| What you see | Likely cause | What to do |
| --- | --- | --- |
| 409 screen_protected | The app on screen sets FLAG_SECURE | observe instead, as above |
| 503 screenshot_failed | The phone returned an empty frame with no protected window on screen | Retry: it is marked retryable |
| A real PNG that is all black | The app is still drawing: a dark splash screen or a video that hasn’t started | Wait for a text with wait_for, then screenshot again |
| A PNG of the wrong app | The app crashed or closed | observe shows the app in front; GET /v1/phones/{id}/apps/{package}/logs shows its last exit |

Every error code is in [errors and recovery](https://mobilebox.dev/docs/errors?via=md).

[Mustafa Yenler](https://mobilebox.dev/about?via=md#mustafa) is the founder of fifteenA and builds Mobilebox, from Berlin and San Francisco. [LinkedIn](https://www.linkedin.com/in/mustafa-yenler)

## Try it in your agent in 60 seconds

Paste this into Claude Code, Cursor, Codex or any agent that can read a web page. It asks for your email, gets its own key at once and adds the phone tools; the 6-digit code from your inbox keeps the workspace.

```
Set up Mobilebox for me: read https://mobilebox.dev/setup.md?via=agent-screenshot-black-flag-secure and follow it.
```

[What your agent reads](https://mobilebox.dev/setup.md?via=agent-screenshot-black-flag-secure)

In this article

[All articles](https://mobilebox.dev/blog?via=md)

## Next question

- [Can I watch my agent work live?](https://mobilebox.dev/live-view?via=next-live)
