Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Mobile app frameworks: Android, iOS, hybrid and PWA

Overview and exam-focused notes on mobile app frameworks: native Android and iOS, hybrid frameworks, and Progressive Web Apps (PWA), with lifecycle diagrams, key syntax, examples and common exam mistakes.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Mobile apps are built using different frameworks depending on performance, development speed and platform reach. Engineers use native, hybrid and progressive web app (PWA) approaches to trade off performance, access to device features, development cost and distribution method.

Key ideas

Define terms first (every term is bolded when first defined):

  • Framework: a collection of libraries and conventions that structure how code is written and run for a class of applications.
  • Native app: an app compiled and built to run with the platform’s native UI and runtime (e.g., Android apps running on Android Runtime (ART) or iOS apps running on iOS runtime). Native apps usually have direct access to platform APIs and offer best performance and UX fidelity.
  • Hybrid app: an app that uses a web engine (a WebView) to render HTML/CSS/JS inside a native shell; native code acts as a thin wrapper and provides a bridge between JavaScript and native APIs (examples: Cordova, Ionic with Capacitor). Assumption: hybrid uses one WebView per app (or per view) and communicates over asynchronous bridges.
  • Progressive Web App (PWA): a web application that uses modern browser features (notably Service Worker and a Web App Manifest) to provide installability, offline behavior and a near-native UX while being delivered via HTTPS (except on localhost during development).
  • Bridge: the mechanism (API/IPC) used to call native functions from JavaScript and vice versa; bridges add latency and complexity and are common in hybrid frameworks and some cross-platform frameworks (e.g., React Native uses a bridge for some operations, though newer versions reduce bridge cost with JSI).
  • Widget / UIViewController / Activity: UI building blocks — on Android the primary component class is Activity (and Fragment for modular UI); on iOS the common controller is UIViewController; in Flutter UI elements are Widgets.
  • Cross-platform native framework: a framework that renders native UI (not in a WebView) and/or uses its own renderer while sharing logic across platforms; examples include React Native (native views with a JS runtime using JSI/TurboModules/Fabric) and Flutter (Skia-based renderer with Dart and platform channels).

Exact behaviors and what to draw/label (for lifecycle diagrams):

  • For Android Activity lifecycle draw six boxes in a vertical stack labelled: Created, Started, Resumed, Paused, Stopped, Destroyed. Draw arrows with method names: Created <- onCreate(Bundle) -> onStart() -> onResume() ; onResume -> onPause() -> onStop() -> onDestroy(). Also draw an arrow from Stopped -> onRestart() -> onStart for restart flows. Label an external event: "Rotate" that triggers destroy and recreate (unless config changes handled).
  • For iOS application lifecycle draw states: Not running, Inactive, Active, Background, Suspended. Label transitions with delegate callbacks: didFinishLaunching -> Inactive -> Active (didBecomeActive), Active -> Inactive (willResignActive) -> Background (didEnterBackground), Background -> Inactive (willEnterForeground) -> Active (didBecomeActive), and termination (willTerminate). Note: On iOS 13+, many UI lifecycle events are also delivered via UIScene/SceneDelegate (e.g., sceneWillEnterForeground, sceneDidBecomeActive), while AppDelegate handles process-level events.

Precise comparisons (assumptions stated):

  • Performance: Native rendering runs UI code on platform-optimized rendering pipelines (assume zero bridge overhead). Hybrid rendering uses WebView’s layout/paint pipeline and has additional JS<->native bridge overhead when calling platform APIs; therefore for rendering-heavy animations native > cross-platform native frameworks (Flutter) > hybrid/PWA (approximate ordering; actual numbers depend on device and implementation).
  • Access to device APIs: Native apps have full API access. Hybrid/PWA can access many APIs via web standards but some privileged APIs (e.g., some background sensors, fine-grained telephony) require native plugins or are unavailable.

Design tradeoffs (listed assumptions):

  • Choose native if maximum performance, tight platform integration, or OS-specific UI conventions are required.
  • Choose hybrid or PWA for faster cross-platform development, easier updates and lower distribution friction (PWA avoids app store but has limited API access). If offline-first and installable from browser, choose PWA.

Formulas

For a programming/topic chapter, list the syntax and small code idioms to remember (each on its own line): override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main) } — Android Activity onCreate (Kotlin). startActivity(Intent(this, DetailActivity::class.java)) — start another Activity (Kotlin). func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool — iOS AppDelegate launch method (Swift). @IBAction func buttonTapped(_ sender: Any) {} — iOS action method (Swift). export default function App() { return (<View><Text>Hello</Text></View>); } — simple React Native component (JSX). void main() => runApp(MyApp()); and class MyApp extends StatelessWidget { @override Widget build(BuildContext context) => MaterialApp(...); } — Flutter main and widget (Dart). navigator.serviceWorker.register('/sw.js').then(reg => { /* success */ }).catch(err => { /* failure */ }) — register a service worker (PWA). self.addEventListener('fetch', event => { event.respondWith(caches.match(event.request).then(...)); }) — service worker fetch handler. { "name": "App Name", "short_name": "App", "start_url": "/index.html", "display": "standalone", "icons": [...] } — Web App Manifest fields.

Worked examples

Example 1 — Android Activity lifecycle trace (diagram answer expected): Question: Show method call sequence and resulting states for: (a) App launched; (b) User presses Home; (c) User re-opens app; (d) Device rotated between launch and resume. Answer (numbered steps):

  1. Launch: onCreate(savedInstanceState) -> onStart() -> onResume(). (State: Resumed / foreground.)
  2. Press Home: onPause() -> onStop(). (State: Stopped / background.)
  3. Re-open: onRestart() -> onStart() -> onResume(). (State: Resumed.)
  4. Rotate (if configuration change not handled): onPause() -> onStop() -> onDestroy() -> onCreate(savedInstanceState) -> onStart() -> onResume(). (State: Resumed.) Explain: draw the diagram from Key ideas and annotate each arrow with these method sequences.

Example 2 — PWA offline caching strategy (cache-first) trace: Question: Write a service worker fetch handler for a cache-first strategy and trace request for /index.html when offline and when online. Answer (code steps then trace):

  1. Service worker (sw.js) code (short):
    • Install event: open cache, add core assets (e.g., '/', '/index.html', '/main.css').
    • Fetch event: event.respondWith(caches.match(event.request).then(res => res || fetch(event.request).then(fetchRes => { caches.open(CACHE).then(c => c.put(event.request, fetchRes.clone())); return fetchRes }))) Trace online request for /index.html: a. fetch event -> caches.match finds resource? assume not -> fetch network -> network response returned and cached. Trace offline request for /index.html after it was cached: b. fetch event -> caches.match finds cached response -> return cached response immediately (offline served). State final: app works offline for cached resources; dynamic update occurs when online and resource updated and cached.

Example 3 — Short model answer: when to pick hybrid vs native for an app that uses camera and real-time AR effects: Answer: AR and camera pipeline require low-latency native access to camera frames and GPU shaders. Use native (or cross-platform native like platform channels in Flutter or native modules in React Native) because hybrid's WebView and bridge add latency and limited access to low-level GPU APIs. Show reasoning: bridge latency + JS single-thread can’t meet <16 ms frame budget, so not suitable.

Common mistakes

  • Mixing up Android Activity lifecycle methods order (common wrong order: putting onPause() after onStop()).
  • Forgetting to handle configuration changes (rotation) leads to unexpected onCreate calls.
  • Running heavy JS on main thread in hybrid/PWA and blaming WebView when the issue is blocking work on UI thread.
  • Thinking React Native has no native code: it does have native modules and sometimes needs platform-specific implementations.

For your exam

Question types you will see

  • Definitions and short notes: define PWA, hybrid, native; list advantages/disadvantages.
  • Diagrams: draw and label Android Activity lifecycle or iOS app lifecycle; annotate transitions for a scenario (e.g., rotation or home button).
  • Code snippets / syntax recall: write service worker registration, Android onCreate skeleton, simple React Native functional component, Flutter main function.
  • Short design/compare question: decide framework for a given app requirement and justify tradeoffs. What a full-marks answer includes
  • Precise definitions with bold terms (if asked), clear assumptions, correct lifecycle diagrams labelled with method names, accurate code or syntax with correct function names and event names, and clear justification for framework choice mentioning performance, API access, and distribution concerns.

Quick check

  1. Name two essential files/features a PWA needs to be installable.
  2. List the three Android Activity callbacks always called in sequence when an Activity first appears.
  3. Why might a hybrid app be slower for complex UI animations than a native app? Answers: Manifest.json (Web App Manifest) and Service Worker; onCreate(), onStart(), onResume(); because the hybrid app renders inside a WebView and must run JS and bridge calls which add latency and do not use the platform’s native rendering pipeline directly.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?