The unit of work is a link or a tap that becomes a route.
The durable artifacts are the parser, the router, and the tests that list accepted and refused links. The main hazard is a parser that grows by accommodation.
Trace a link from a message. The system matches the intent filter and starts or reuses the activity. The activity passes the string to the parser. A route goes to the router and the stack changes. A null does nothing. The screen is derived from the top of the stack, never the other way around.
Capture the baseline with ./gradlew :features:test --tests "*NavigationTest". Add a new accepted link shape with the failing test first, then the parser change, then a refused neighbour. Record the diff.
Read the parser diff for what it newly accepts. Ask what an attacker would write against the new rule. Check the order of operations: validate first, then decode, then use.
When a link opens the wrong screen, log the raw string at the parser and the route it returned, with the host replaced by a placeholder if it is sensitive. When a restore shows a stale screen, check the saver’s decode on the saved list.
Check that the app accepts one scheme and a known host list, that identifiers match a strict pattern, that no query or fragment reaches business logic unvalidated, and that an exported activity has no intent filter that is broader than the parser.
Test both directions. The accepted list proves the app opens real links. The refused list proves it ignores bad ones. Test the router for repeats and the root, and test the saver for round trips and garbage. Device checks of verified links need a real domain and are done by hand with adb.
Review any new link shape as a security change. Keep the manifest and the parser in the same pull request. Publish the supported link shapes in one place, so marketing and support do not invent new ones.
- Hosts are compared as whole values against an allowlist.
- Identifiers match a pattern before use.
- Encoded input is refused or decoded before validation, never after.
- The saved back stack is decoded as untrusted.
- Link verification is tested on a real device before release.
- Why does the parser refuse percent signs instead of decoding them?
- What does
singleTopchange about the back stack? - What does
autoVerifyadd that the parser cannot? - Why can the root never be popped?
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.
