Type to search pages and rules.

Use with Agents

Android Stack

Stack: androidConcern: frontend-ui

The Android stack is the technology binding for a product that ships a native Android application built with .NET for Android in C# against plain Android views. A team chooses it with either shape, client-only or server, declared in Supported Scope. This frontend sits outside the controlled UI contract, which covers React and Svelte only, so its entry point record names the boundaries that replace that contract.

Markdown17 rules
On this page

Concepts#

What the Stack Holds#

The stack is one native Android application: a .NET for Android project holding the screens, the navigation controller, and the device code, built against plain Android views. It publishes an AAB through the .NET toolchain, which builds, tests, and publishes the whole mobile solution. The shared mobile pages in the Mobile overview state the rules every mobile stack follows, and the Technology Stacks page states the rules every stack shares.

Version Pins#

The stack.dotnet key in litespec.manifest.yaml pins the .NET version, the stack.android key pins the Android API level, and the packages.nuget keys pin every NuGet package version. These keys name the pins; the manifest holds the values.

Structure Bindings#

The platform project is {ProjectName}.Android. It holds the host Activity, the navigation controller, the Screens/ folder, the platform adapters, and the Resources/ folder. The core projects hold the rest: Domain, Application, and Infrastructure, with the Client project added on the server shape.

Rendering Bindings#

Screens are plain Android views that the navigation controller shows, and the host Activity owns the controller. Back, insets, and saved state are platform APIs of the Activity and its window, not of a UI library.

Component Bindings#

Colors and text styles live in resources, and screen code draws with plain Android views. The stack has no page-code lint, so the entry point record names the review that replaces it.

Route Entry Bindings#

A route entry is one screen class under Screens/. The host Activity and failure views are not route entries, and they carry no screen mark.

Data Bindings#

The app keeps its persisted state in app-private storage and reads it through the typed store. The server shape adds the {ProjectName}.Client project, which holds the generated API client.

Testing Bindings#

Core tests run as plain .NET test projects with no emulator. Device tests run on an emulator or a device. The manifest pins no device-test library.

UI Bindings#

Screens draw with native Android views, and this frontend sits outside the controlled UI contract, so it has no registry build command. Its entry point record names the checks that replace it.

Standards#

Keep the Android Frame, Routes, and Modules#

rulerequiredguidance
litespec/frontend/mobile/android/stack#keep-the-android-frame-routes-and-modules
Statement

An Android frontend MUST hold its frame in the host code of the platform project, its routes as screen classes under Screens/, and its use-case code as Application handlers.

Why

Three fixed homes let a reader and a tool find the frame, the screens, and the use-case code in the same place in every Android app.

Example

The Claimwick Android app keeps its navigation host in Claimwick.Android, the expense list screen in Screens/Expenses/, and the expense handlers in the Application project.

Checka reviewer answers

Reviewed forWhich screen classes sit outside Screens/, or hold use-case logic instead of calling Application handlers? Look in the platform project and the core projects.

Marked guidance: a reviewer answers this question.

Mark Each Android Screen with Its Screen Record#

rulerequiredguidance
litespec/frontend/mobile/android/stack#mark-each-android-screen-with-its-screen-record
Statement

A screen class under Screens/ MUST carry the <implements> mark of the screen it renders, in the form the .NET stack states.

Why

The mark links the screen to its record the way a .NET handler carries its use-case mark, so the builder and the check read one link.

Example

ExpenseListScreen carries /// <implements>screen/claimwick-app.expense-list</implements>.

Checka reviewer answers

Reviewed forWhich screen classes under Screens/ lack a screen mark? Look in each screen file.

Marked guidance: a reviewer answers this question.

Keep Hosts and Failure Views Unmarked#

rulerequiredguidance
litespec/frontend/mobile/android/stack#keep-hosts-and-failure-views-unmarked
Statement

A host Activity or a failure view MUST NOT carry a screen mark.

Why

A host or failure view draws no screen of its own, so a mark on it links an address to a screen it does not show.

Example

The host Activity class carries no <implements> mark.

Checka reviewer answers

Reviewed forWhich host Activities or failure views carry a screen mark? Look in the platform project.

Marked guidance: a reviewer answers this question.

Hold One Navigation Controller in the Platform Project#

rulerequiredguidance
litespec/frontend/mobile/android/stack#hold-one-navigation-controller-in-the-platform-project
Statement

The Android app MUST hold its navigation controller in one class in the platform project, owned by the host Activity.

Why

One controller holds the current screen, the open overlay, and the history, so no screen navigates on its own.

Example

The Claimwick controller is one class that the host Activity creates and that every expense screen raises events to.

Checka reviewer answers

Reviewed forWhich screens navigate without the controller, or which second controller holds navigation state? Look in the screen classes and the host Activity.

Marked guidance: a reviewer answers this question.

rulerequiredguidance
litespec/frontend/mobile/android/stack#accept-app-links-in-the-host-activity
Statement

The host Activity MUST receive app links in OnCreate and OnNewIntent, through an IntentFilter with AutoVerify set.

Why

Handling both entry points lets a cold start and a link that arrives while the app runs open the same screen, and AutoVerify lets the platform open the app instead of a browser.

Example

A link to https://claimwick.example/claims/ opens the claim screen named by its path, whether the app was closed or open.

Checka reviewer answers

Reviewed forWhich app links the host Activity misses on a cold start or while running? Look at the intent filter and both overrides.

Marked guidance: a reviewer answers this question.

Route the Back Gesture Through the Activity Dispatcher#

rulerequiredguidance
litespec/frontend/mobile/android/stack#route-the-back-gesture-through-the-activity-dispatcher
Statement

The host Activity MUST deliver the system back gesture to the navigation controller through its OnBackInvokedDispatcher.

Why

The dispatcher is the platform's own path for the back signal, so predictive back reaches the controller as the same overlay-then-screen-then-leave order on every screen.

Example

A back gesture on the expense detail screen closes an open overlay first, then steps back to the expense list.

Checka reviewer answers

Reviewed forWhich back gestures bypass the Activity's dispatcher, or leave the app from a screen other than the first? Look in the host Activity and the controller.

Marked guidance: a reviewer answers this question.

Apply System Insets to Each Screen#

rulerequiredguidance
litespec/frontend/mobile/android/stack#apply-system-insets-to-each-screen
Statement

A screen MUST apply the system bar and display cutout insets it reads from WindowInsets to its controls and text.

Why

The window supplies these insets, so reading them from WindowInsets keeps controls and text clear of the bars and cutouts on every device.

Example

The expense claim screen pads its submit button by the system bar inset while its background draws full bleed.

Checka reviewer answers

Reviewed forWhich screens place a control or text under a system bar or a cutout? Look in the screen layouts and the inset handling.

Marked guidance: a reviewer answers this question.

Store Navigation State in the Activity Bundle#

rulerequiredguidance
litespec/frontend/mobile/android/stack#store-navigation-state-in-the-activity-bundle
Statement

The host Activity MUST save the navigation controller's state in its Bundle from OnSaveInstanceState and restore it in OnCreate.

Why

The platform ends the process in the background when memory runs short, and the saved bundle returns the visitor to the same screen with the same overlay and history.

Example

After the platform ends the Claimwick process, the app reopens on the expense detail screen with its overlay still open.

Checka reviewer answers

Reviewed forWhich navigation state the controller holds outside the saved bundle? Look in the host Activity and the controller.

Marked guidance: a reviewer answers this question.

Keep Screen Styles in Resources#

rulerequiredguidance
litespec/frontend/mobile/android/stack#keep-screen-styles-in-resources
Statement

A screen MUST take its colors and text styles from Resources/values/styles.xml and set no style value in code.

Why

Resources hold every color and text style in one place, and a screen that sets a value in code is a second style that no resource answers to.

Example

The expense total uses the TotalText style from Resources/values/styles.xml and sets no color in its screen class.

Checka reviewer answers

Reviewed forWhich screen classes set a color, font, or margin in code? Look in the screen classes.

Marked guidance: a reviewer answers this question.

Read Android Copy Through the Generated Resource Class#

rulerequiredguidance
litespec/frontend/mobile/android/stack#read-android-copy-through-the-generated-resource-class
Statement

A screen MUST read every copy string through the generated Resource class, with its fallback in Resources/values/strings.xml.

Why

The generated class gives every copy key a typed name, and the default values folder gives every key a fallback when a language lacks it.

Example

The expense list reads its empty-state sentence as Resource.String.ExpenseListEmpty, and the Spanish file supplies the translation.

Checka reviewer answers

Reviewed forWhich copy strings a screen reads by a literal name instead of the generated class? Look in the screen classes and the layouts.

Marked guidance: a reviewer answers this question.

Store Persisted State in App-Private Storage#

rulerequiredguidance
litespec/frontend/mobile/android/stack#store-persisted-state-in-app-private-storage
Statement

Persisted state and user media MUST live under Context.FilesDir, written atomically.

Why

The app's own sandbox keeps the data away from other apps and the shared media library, and an atomic write keeps the previous complete file if a write stops midway.

Example

The expense receipts the visitor adds are copied into the app's files directory and replace their previous copy only after the new one is whole.

Checka reviewer answers

Reviewed forWhich persisted state or user media sits outside Context.FilesDir, or is written in place? Look in the storage adapters.

Marked guidance: a reviewer answers this question.

Use the System Pickers for Media#

rulerequiredguidance
litespec/frontend/mobile/android/stack#use-the-system-pickers-for-media
Statement

A screen MUST pick photos through the Photo Picker action android.provider.action.PICK_IMAGES and files through android.intent.action.OPEN_DOCUMENT.

Why

Both pickers grant access to the chosen items only, so the app needs no storage permission to read one receipt.

Example

Adding a receipt photo opens the Photo Picker, and the visitor's choice is the only image the app receives.

Checka reviewer answers

Reviewed forWhich screens pick photos or files through another intent, or request a storage permission to do so? Look in the picking call sites and the manifest.

Marked guidance: a reviewer answers this question.

Request Permissions at the Point of Use#

rulerequiredguidance
litespec/frontend/mobile/android/stack#request-permissions-at-the-point-of-use
Statement

The Android app MUST request each runtime permission through RequestPermissions when the action that needs it starts, never in OnCreate.

Why

A request at the point of use arrives when the visitor knows what it is for, and the same permission answers a question the visitor just asked.

Example

The camera permission is requested when the visitor taps Scan receipt, not at launch.

Checka reviewer answers

Reviewed forWhich runtime permissions are requested in OnCreate or before the action that needs them? Look in the host Activity and the action handlers.

Marked guidance: a reviewer answers this question.

Request Audio Focus Before Playing Sound#

rulerequiredguidance
litespec/frontend/mobile/android/stack#request-audio-focus-before-playing-sound
Statement

A screen that plays sound MUST request audio focus with an AudioFocusRequest before it plays, and pause when focus is lost.

Why

One speaker serves every app, so the platform arbitrates only the apps that ask for focus, and pausing on loss yields to navigation prompts and calls.

Example

A confirmation chime plays only after the app holds audio focus, and a phone call pauses it.

Checka reviewer answers

Reviewed forWhich sound playback runs without an AudioFocusRequest, or keeps playing after focus is lost? Look in the playback call sites.

Marked guidance: a reviewer answers this question.

Run Android Core Tests on xunit.v3#

rulerequiredguidance
litespec/frontend/mobile/android/stack#run-android-core-tests-on-xunitv3
Statement

The Android app MUST run its core tests as plain .NET test projects on xunit.v3, the version packages.nuget pins.

Why

Core tests need no emulator, so a plain .NET runner keeps them fast, and one pinned runner keeps every core project on the same version.

Example

The expense claim rule has its test in an xunit.v3 project beside the Domain project it proves.

Checka reviewer answers

Reviewed forWhich core tests run on another runner, or need an emulator or device? Look in the core test projects.

Marked guidance: a reviewer answers this question.

Keep Android Core Test Mocks to the Owned Boundaries#

rulerequiredguidance
litespec/frontend/mobile/android/stack#keep-android-core-test-mocks-to-the-owned-boundaries
Statement

A core test MUST NOT replace the Domain types or the Application handlers it proves.

Why

A stand-in for the code under test proves the stand-in, so the test reaches the rule only through the real types and handlers.

Example

The expense claim test builds a real Domain claim and calls the real submit handler, and replaces only the platform storage adapter.

Checka reviewer answers

Reviewed forWhich core tests replace a Domain type or an Application handler? Look in the test doubles.

Marked guidance: a reviewer answers this question.

Declare Android Outside the Controlled UI Contract#

rulerequiredguidance
litespec/frontend/mobile/android/stack#declare-android-outside-the-controlled-ui-contract
Statement

An Android frontend MUST declare an entry point record naming Android and the boundaries that replace the controlled UI contract.

Why

The controlled contract covers React and Svelte, so an Android frontend declares what replaces its checks instead of reporting as one with nothing to check.

Example

The Claimwick Android entry point record names Android and the native view review that replaces the controlled contract.

Checka reviewer answers

Reviewed forWhich Android frontends declare no entry point record naming Android and its replacement boundaries? Look in the entry point records.

Marked guidance: a reviewer answers this question.

Conventions#

None.