NNabeel Hassan

Blog · November 19, 2026 · 8 min read

Recording Long Audio in a Mobile App: How to Never Lose an Hour-Long Recording

By Nabeel Hassan — AI Engineer · ICPC World Finalist

TL;DR: Recording an hour of audio on a phone sounds like one API call. In practice it is a reliability problem: the screen locks, a phone call interrupts, the OS kills the app, the disk fills, the battery dies, and the upload has to cross a weak campus Wi-Fi connection. My rules for any app where a long recording is the core action: configure the audio session for background recording and handle interruptions explicitly, write the recording to disk in short segments so a crash loses seconds and not the whole hour, record in a compressed speech-friendly format at the source, upload segments in the background with resumable retries, and make the recording state impossible to misread in the interface. The user only records a lecture once. If you lose it, there is no second take.

On LectureNotes AI, the AI note-taking app I co-founded, the core action is simple to describe: a student presses record at the start of a lecture, and some time after it ends they get a summary and a clean outline. Everything people talk about is the AI part. But the transcription and the summary are only as good as the audio that reaches the server, and getting a full lecture from a phone on a desk to a server, intact, is its own engineering job.

I touched on this in speech-to-text for lectures vs phone calls, where the point was that the capture path matters more than the model. This post is the practical version: what has to be true for a long recording on a phone to be reliable.

Why long recordings fail

A thirty second voice memo almost never fails. An hour-long recording fails in ways that only show up because of the duration:

Each one is rare per minute. Over sixty minutes, across thousands of recordings, every one of them happens daily. And the user usually finds out only after the lecture is over, which is the worst possible time.

Get the audio session right first

Both iOS and Android will let you record in the background, but only if you ask properly.

On iOS, that means the background audio capability in the app's configuration, an audio session category that supports recording, and activating the session before you start. On Android, it means a foreground service with a persistent notification and the microphone service type, because modern Android restricts background microphone access for anything that is not visibly running.

That persistent notification is useful, not just required: it tells the user from the lock screen that the recording is still running.

If you are building in React Native or Flutter, check exactly what your recording library does here rather than assuming. Long background recording is one of the places where I am most likely to drop down to a small native module, the same way I describe in writing native plugins for iOS and Android. A thin native layer that owns the audio session beats a cross-platform package that half-handles it (more in React Native vs Flutter vs native).

Handle interruptions explicitly

An interruption is not a crash, and it should not end the recording silently.

When the system tells you the audio session was interrupted, the recorder should:

  1. Mark the gap. Close the current segment and record that an interruption started at this time.
  2. Show it. The interface should say "Recording paused: phone call" in plain words, not keep a timer ticking as if nothing happened.
  3. Resume when allowed. When the interruption ends, try to reactivate the session and start a new segment. If the system does not allow an automatic resume, tell the user clearly and, where it makes sense, send a local notification so a student who took a call in the corridor knows to come back and tap resume.
  4. Keep the gap in the data. The server should know there is a missing stretch, so the transcript and summary do not stitch two halves of a lecture together as if they were continuous.

The worst outcome is a recording that quietly stopped at minute twelve while the on-screen timer kept counting.

Write to disk in segments, not one file

This is the single change that removes the most heartache.

If the app writes one big file and only finalizes it when the user presses stop, any crash, kill or battery death before that moment can leave a file that is corrupt or missing entirely. An hour of audio depends on one clean shutdown that may never come.

Instead, I record in short segments, a few minutes each, and finalize every segment as it closes. Each segment gets a sequence number and a start time, and a small local manifest tracks which segments belong to which recording.

What this buys you:

The manifest is the source of truth for local state. Write it atomically, and never delete a segment until the server has confirmed it.

Pick the format at the source

Uncompressed audio from a phone microphone is large, and an hour of it is a painful upload on mobile data. Speech does not need music-grade fidelity.

My default for speech is a compressed format the platform encodes natively, mono, at a sample rate that speech-to-text models handle well. That keeps an hour of audio small enough to upload comfortably while leaving plenty of quality for transcription. Two rules:

Smaller files also feed straight into cost. Storage, bandwidth and transcription time all scale with what you upload, and I covered why that matters for free tiers in AI app unit economics.

Upload in the background, resumably

Students record on crowded campus Wi-Fi that drops when they walk between buildings. Uploading one large file in the foreground after the recording ends will fail often and feel slow even when it works.

What works better:

When processing finishes, a "your notes are ready" notification is one of the few pushes users genuinely want. I wrote about that pattern in push notifications for a small app.

Make the recording state impossible to misread

Most lost recordings I would call "user error" are really interface errors. A good recording screen answers three questions at a glance, even from across a desk:

Check storage before starting. If there is not enough room for the expected length, say so up front, and keep checking during the session so you can warn before the disk is full rather than failing at minute fifty.

Monitor the pipeline, not just the crashes

Crash reporting catches the loud failures. Most recording failures are quiet: a recording that ended early, a segment that never uploaded, a session with a long gap. These do not crash anything.

So I track recording health as its own set of events: recordings started, recordings stopped normally, recordings recovered after a crash, interruptions per hour of audio, segments uploaded vs segments recorded, and time from stop to "notes ready". A sudden drop in "stopped normally" after a release is a regression even if the crash rate did not move. I go deeper into setting up those alerts in error monitoring and alerting for a small product.

Testing it the way students use it

Simulators hide most of these failures. Before a recording feature ships, I run it on real iOS and Android devices through the ugly cases:

  1. Lock the screen and leave it for a full hour.
  2. Take a phone call mid-recording, and decline one.
  3. Trigger an alarm and a voice assistant.
  4. Force-kill the app mid-recording, then relaunch and confirm recovery.
  5. Fill the storage nearly full and start a recording.
  6. Start in low power mode with a low battery.
  7. Switch networks during upload, and go fully offline, then back online.
  8. Update the app while a recording is unuploaded, and confirm the new version still finds and uploads it.

That last one is easy to forget. If the manifest format changes between versions, an update can orphan audio the user cares about. The same "add fields, never repurpose them" rule from keeping old mobile app versions working applies to local data too.

The honest summary

The AI in a lecture-notes app gets the attention, but students do not forgive a lost lecture, whatever the cause. Background audio set up properly, explicit interruption handling, segmented writes with recovery, background resumable uploads and a recording screen nobody can misread are not glamorous. They are what makes the AI part worth anything.


I build mobile apps and AI products for startups in the US, UK and Europe, including the unglamorous capture and upload pipelines that the AI depends on. If your app records audio, video or sensor data and you need it to survive real-world conditions, read more about my background or book a call.

FAQ

How do you record audio in the background on iOS and Android?

On iOS, enable the background audio capability, use an audio session category that supports recording and activate the session before you start. On Android, run the recorder in a foreground service with a persistent notification and the microphone service type, because modern Android restricts background microphone access for anything not visibly running.

What happens to a recording when a phone call comes in?

The system interrupts the audio session. A reliable recorder closes the current segment, marks the gap, shows a clear paused state, and resumes into a new segment when the interruption ends, or tells the user to tap resume if the system does not allow it. The gap should be kept in the data so the transcript does not stitch two parts together as if they were continuous.

How do you stop a crash from losing a long recording?

Write the recording to disk in short segments of a few minutes, finalize each one as it closes and track them in a small local manifest. A crash then loses at most the current segment, and on the next launch the app can find the unfinished recording and offer to process what was saved.

What audio format should a speech recording app use?

A compressed format the platform encodes natively, in mono, at a sample rate speech-to-text models handle well. It keeps an hour of audio small enough to upload on mobile networks with plenty of quality for transcription. Decide the format on the device and avoid converting or upsampling on the server, which costs compute and adds nothing.

Building something in this space?

I take on AI-agent, automation and product work directly — scoped fast, shipped fast.

Book a discovery call →

Keep reading