Planning permission-aware Android background work

← Back to Blog & Articles

The unit of work is a capability the user can take away.

The durable artifacts are the permission rule, the attachment policy, the sync plan, and the manifest. The main hazard is the happy path that fails on a device the developer does not own.

Trace a photo. The user taps Add photo, the system picker returns a URI, the screen reads its metadata, the policy accepts or refuses, and an accepted photo is queued through the repository. The permission rule is not on this path, because no permission is needed.

Capture the baseline with ./gradlew :features:test --tests "*DeviceRulesTest". Add a failing test for a new allowed type, then the type, and then a refused neighbour. Run the app and pick one image of each type.

Read the manifest diff first. A new permission, service, or receiver needs a reason. Then read each adapter for a branch that should be a rule, and each rule for an input it trusts.

When a feature works on one device and not another, record the Android version, the manufacturer, and the permission state. Many failures follow the platform version, the battery policy, or a vendor’s background limit, and none can be reproduced on a clean emulator.

Check that no permission is declared without a use, that file names are sanitized, that content URIs are read once and not stored, that background work holds no credentials in its input, and that notification payloads name routes only.

Rules are verified on the JVM. Platform behavior is verified on real devices, across at least three Android versions and two manufacturers, by hand, with a written checklist. Say in the release notes which was done.

Keep a device matrix and update it when support changes. Review permission requests as product changes. Re-test background work after every WorkManager or Android update.

  • Every permission in the manifest has a use and an owner.
  • Photos use the picker unless a documented need says otherwise.
  • File names and types from outside are validated.
  • Background work is unique, constrained, and bounded in retries.
  • Push payloads are versioned and parsed strictly.
  • Why does the rationale flag not mean “permanently denied”?
  • What does the photo picker give the app that a permission does not?
  • What happens to a periodic request for five minutes?
  • Why does the worker not retry an authorization failure?

Continue with the book

Explore the full treatment, worked examples, and exercises in Agentic Android App Development.


Companion article for Agentic Android App Development, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.

Scroll to Top