DEV Community

Cover image for What Android 14, 15 and 16 still let a background video recorder do
TheChemical
TheChemical

Posted on

What Android 14, 15 and 16 still let a background video recorder do

I work on XSCamera, a background video recorder for Android. It records with the screen off or while you use another app. It has a bit over 6 million installs, which mostly means we get to find every edge case in production.

People regularly ask whether this kind of app is "still possible" on new Android versions. It is. But the list of things you must do correctly gets longer every year, and the failure mode is nasty: the app installs, the button works, and the recording silently never starts or dies ten minutes in.

This is the short version of what we've learned. If you're building anything that holds the camera or microphone while the user is elsewhere (a dashcam, a baby monitor, a bodycam for cyclists), most of it applies to you.

The rules, by version

Android versions and what each one changed for background camera use

Android 9 cut off camera and microphone access for apps that are idle in the background. From here on you need a foreground service, and a foreground service means a notification. That's the end of "invisible" recorders, seven years ago now.

Android 10 and 11 introduced foregroundServiceType and then enforced it for camera and microphone. A service that touches the camera without camera in its type gets nothing but black frames or an exception, depending on the device.

Android 12 did two things. It added the green privacy indicator, which the system draws and you cannot influence. And it blocked starting a foreground service from the background in most cases (ForegroundServiceStartNotAllowedException). In practice: start the service while your activity is visible, in response to a tap.

Android 13 made the notification permission a runtime permission, and gave users a "stop" button for foreground services in the notification drawer. If your service is stopped from there, you get no polite callback. Plan for it.

Android 14 is the one that broke old apps. Every foreground service must declare a type, each type needs its own permission (FOREGROUND_SERVICE_CAMERA, FOREGROUND_SERVICE_MICROPHONE), and the system checks at start time that you actually hold the runtime permission for that type. Miss any of it and startForeground() throws a SecurityException.

Android 15 tightened what may be started from BOOT_COMPLETED. A camera service started at boot is not allowed.

The minimum that works

Manifest:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<service
    android:name=".RecordingService"
    android:exported="false"
    android:foregroundServiceType="camera|microphone" />
Enter fullscreen mode Exit fullscreen mode

Starting it, from an activity that is on screen:

// In the activity, after CAMERA and RECORD_AUDIO are granted
ContextCompat.startForegroundService(this, Intent(this, RecordingService::class.java))
Enter fullscreen mode Exit fullscreen mode
// In the service
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
    val types = ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA or
        (if (recordAudio) ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE else 0)
    ServiceCompat.startForeground(this, NOTIFICATION_ID, buildNotification(), types)
    openCameraAndRecord()
    return START_NOT_STICKY
}
Enter fullscreen mode Exit fullscreen mode

Two details in there are not decoration.

Only pass the microphone type if you hold RECORD_AUDIO. If the user turned sound off and denied the permission, including that type throws on Android 14.

And START_NOT_STICKY is deliberate. If the system kills you and restarts the service later, you're now a service started from the background, which can't get the camera. Better to stop cleanly and tell the user than to come back as a zombie holding a notification and recording nothing.

The order of events that keeps camera access after the screen turns off

The bugs that actually cost us

The timestamp overlay. Our users like a date and time burned into the video. In one release line we drew that overlay on the main thread, once per frame. On fast phones nobody noticed. On slow ones, with a 4K preview, the main thread fell behind, and our ANR rate climbed from 0.28% to 0.40%. Google's bad-behaviour threshold is 0.47%, and Play shows your app less once you cross it, so that was close enough to ruin a week. The fix was boring: the overlay got its own thread. The lesson was less boring. A camera app has a hot loop, and anything on the main thread inside it is a liability on a 2 GB phone, even if it profiles fine on your desk.

Battery managers. A correct foreground service is still not safe on many phones. Samsung, Xiaomi, Oppo and Vivo all ship their own task killers on top of Android's. The only real fix is on the user's side (battery set to Unrestricted, autostart on Xiaomi), so the app has to detect the situation and explain it, with the exact path for that manufacturer. dontkillmyapp.com keeps the list. We read 2,187 low-star reviews across the big apps in this category and "it stopped by itself" was the number one complaint, 340 of them. Most of those are this.

The file that won't play. A normal MP4 gets its index written when recording stops. If the process dies first (battery killer, crash, full disk), you have a large file that no player will open. It was the smallest group in those reviews, 115, and the angriest. If you record long sessions, don't rely on a clean stop: write in segments or use a container layout that stays readable. Then test it by killing your own process mid-recording.

Storage. 4K runs about 350 MB a minute. Users don't do that maths, so do it for them and show the remaining minutes before they press record.

What I'd check before shipping

Checklist for a background camera service

  • Service declares camera (and microphone if used), with both FOREGROUND_SERVICE_* permissions in the manifest.
  • Service is started from a visible activity, after the runtime permissions are granted.
  • The types passed to startForeground() match the permissions you hold right now.
  • The notification is real and useful: what's recording, for how long, a Stop action. Reviewers at Play look at this, and so do users.
  • Nothing per-frame runs on the main thread.
  • Kill the process mid-recording. Is the file playable?
  • Run it for an hour with the screen off on a Samsung and a Xiaomi with default battery settings. Then with Unrestricted. Know the difference and tell your users.
  • Fill the storage during a recording. Do you stop cleanly?
  • Fill in Play Console's foreground service declaration and record the demo video before you upload, not after the rejection.

One more thing

Don't promise hidden recording in your listing. It isn't possible, so it's a false claim, and Play removes apps for it under the stalkerware policy. The honest pitch (keeps recording when the screen is off, always shows that it is recording) is also the one that survives review.

I'm on the team behind XSCamera at XS Labs. The review counts come from our own read of public Play reviews in November 2026. If something here is wrong for a device you know well, I'd like to hear it.

Top comments (0)