Implementation Manual

Technical Implementation Manual for Developers Version 1.0 - Android-Specific Code Specifications


Executive Summary

This technical manual provides Android-specific implementation specifications for developers building health supply chain management systems based on the AI Health Supply Chain Optimization Framework. This document addresses critical code-level requirements that prevent application crashes, battery drain, and data corruption in low-resource humanitarian settings.

triangle-exclamation

Target Platform

Specification
Requirement

Android OS

Minimum SDK 26 (Android 8.0), Target SDK 33 (Android 13)

Device Specs

2GB RAM minimum, 16GB storage, 5-inch display (480x800px)

Architecture

ARM-based processors (ARMv7/ARMv8)

Development Language

Kotlin preferred, Java acceptable


Critical Development Requirements

circle-exclamation

Background Synchronization Implementation

Android WorkManager (Required)

triangle-exclamation

Implementation Specification

Key Configuration Parameters

Parameter
Purpose

NetworkType.CONNECTED

Sync only when ANY network available (WiFi or cellular)

RequiresBatteryNotLow

Prevents sync when battery <20%

PeriodicWorkRequest

24-hour repeat interval with 4-hour flex window

ExistingPeriodicWorkPolicy.KEEP

Prevents duplicate work requests

"facility_sync"

Unique work name ensures only one sync worker instance

SyncWorker Implementation

Error Handling

Return Value
Use Case

Result.retry()

Transient failures (network timeout, server error)

Result.failure()

ONLY for permanent errors (auth token expired)

WorkManager automatically implements exponential backoff for retry().


Local Database Implementation

SQLite WAL Mode (Required)

triangle-exclamation

Room Database Configuration

circle-info

Key Requirement: .setJournalMode(JournalMode.WRITE_AHEAD_LOGGING)

This MUST be set during database initialization. Do not rely on default mode.

WAL Checkpoint Management

WAL mode creates separate log files that can grow large. Force checkpoint after every successful sync to maintain <50MB database footprint:

Database Schema


Security and Encryption Implementation

Android Keystore System (Required)

triangle-exclamation

Key Generation and Storage

EncryptedSharedPreferences for Local Data

For storing authentication tokens, user IDs, and facility codes locally:

circle-exclamation

DHIS2 Integration and Local Caching

Local Morbidity Data Cache (Required)

triangle-exclamation

Local Cache Structure (JSON)

Cache Update Implementation

Fraud Detection Using Local Cache


User Interface Implementation

Spinner Components for Structured Data (Required)

triangle-exclamation

String Resources Definition

res/values/arrays.xml:

Layout Implementation (XML)

Kotlin Logic

Auto-Save Implementation

To reduce user burden, implement automatic saving on field completion (no explicit save button):


Critical Implementation Reminders

Component
Wrong Implementation
Correct Implementation

Background Sync

AlarmManager with fixed time

Android WorkManager with network constraints

Database Mode

Default SQLite mode

WAL mode with PRAGMA journal_mode=WAL

Encryption Keys

Hardcoded in source or SharedPreferences

Android Keystore System

DHIS2 Queries

Live API calls during fraud checks

Local JSON cache updated during sync

Override Reasons

EditText for free text entry

Spinner with string resources


Document Information

Field
Value

Version

1.0

Date

December 2025

Organization

International Foundation for Recovery and Development (IFRAD)

Last updated