Originally answered on Quora: "How do you record a video with the screen off in Android?" . This is the dev.to canonical — the long, code-level version of the same architecture, written for developers shipping a camera-adjacent Android app. If you've tried to build an Android camera app that records with the screen off, you've hit the wall I'm about to describe. The Camera2 session works fine while the app is foregrounded. You lock the screen. A few seconds later — sometimes thirty, sometimes ten minutes, sometimes after a Doze maintenance window — the frames stop. No exception, no broken pipe, no helpful log. Just silence.…