Activity lifecycle
Learn how Android calls onCreate, onStart, onResume, onPause, onStop and onDestroy, and how to keep user state across rotation with onSaveInstanceState.
Read →Deep technical articles on Android engineering, Kotlin internals, and software systems. Based on the Code From Scratch YouTube series.
Filter by category
Learn how Android calls onCreate, onStart, onResume, onPause, onStop and onDestroy, and how to keep user state across rotation with onSaveInstanceState.
Read →See how Android is built in layers, what the four app components do, how apps run on ART in isolated processes, and what the manifest and permissions declare.
Read →Learn how Android detects an ANR: input and broadcast timeouts, main-thread blockers, how to read ANR traces, StrictMode, and why coroutines do not prevent it.
Read →Follow an Android cold start from tap to first frame: Zygote fork, Application.onCreate, layout inflation, cold, warm and hot starts, and baseline profiles.
Read →Learn when caching helps and when it hurts: LRU eviction, memory and disk caches, cache invalidation, Coil and Glide internals, OkHttp caching and cache sizing.
Read →Learn how Kotlin coroutines pass data through channels: send and receive, rendezvous, buffered, unlimited and conflated types, closing, and for-loop consumers.
Read →Learn to define Kotlin classes with primary and secondary constructors, init blocks, custom accessors, data classes, object singletons and companion objects.
Read →Learn what lists, sets and maps are, when each one fits, which operations they share, and why your code must handle empty and nested collections.
Read →Learn how records, tuples and choice types combine simple values into data models, why compilers check every case, and why composition often beats inheritance.
Read →Apply the CAP theorem to Android apps: staleness, optimistic updates, last-write-wins, merging, CRDTs, eventual consistency and optimistic concurrency control.
Read →Learn what a context switch costs: register saves, CPU cache misses, why 100 threads on 8 cores run slower, and how Dispatchers.Default and coroutines avoid it.
Read →Learn how if and when work as expressions in Kotlin, how for loops use ranges, until, step and downTo, and when to use while, do-while, break and continue.
Read →Learn what CoroutineContext holds, how Dispatchers.Main, IO and Default differ, how withContext switches threads, and how child coroutines inherit context.
Read →See what the Kotlin compiler generates for a suspend function: the Continuation parameter, CPS, the label state machine, COROUTINE_SUSPENDED and resumption.
Read →Learn to tell CPU-bound from IO-bound work, why Dispatchers.Default and Dispatchers.IO exist, how to classify Android tasks and when to switch with withContext.
Read →Learn how programs represent real-world information as data, how types define valid values and operations, and how static and dynamic typing catch type errors.
Read →Learn where to validate input data, which checks to apply, why you fail fast with clear errors, and how invariants, sanitization and defense in depth help.
Read →Learn how a program checks a true or false condition against current state, takes one branch, skips the other, and handles three outcomes with chained checks.
Read →Learn why injected dependencies make Android classes testable, and how Hilt wires them with @Inject, @Provides modules, scopes and @HiltViewModel.
Read →Learn how Kotlin dispatchers pick a thread: Main, Main.immediate, Default, IO and Unconfined, plus withContext, structured concurrency and cancellation.
Read →I measured MTP speculative decoding on an Apple M2 Ultra: +92% on a dense 27B model, -19% on a 35B MoE model.
Read →See how exceptions propagate in Kotlin coroutines, why you rethrow CancellationException, and how CoroutineExceptionHandler, SupervisorJob and Flow catch work.
Read →Learn the difference between bugs and expected failures, why failure is part of program behavior, how testing detects it, and how to ask what could go wrong.
Read →Learn to add functions and properties to existing Kotlin types without inheritance, how the receiver works, why members win, and how nullable receivers help.
Read →Learn how Kotlin Flow returns many values over time, why a cold flow runs again for each collector, and how flow builders, emit, collect and backpressure work.
Read →Learn how intermediate and terminal Kotlin Flow operators build pipelines, from map, filter and take to combine, zip, flatMapConcat, toList and reduce.
Read →Learn to declare Kotlin functions with fun, typed parameters and return types, write single-expression functions, and use default values and named arguments.
Read →Learn how garbage collection works: roots and reachability, the generational hypothesis, Eden and survivor spaces, ART's concurrent copying GC and finalizers.
Read →Learn where Kotlin objects live: stack frames and references, heap objects and the garbage collector, primitives and boxing, val vs var, and stack limits.
Read →Follow Kotlin code from source to CPU: JVM bytecode, D8 and DEX, JIT and AOT compilation in ART, and the fetch, decode, execute loop with registers and the ALU.
Read →Learn why Android retries need idempotent operations: HTTP method semantics, idempotency keys, how Stripe uses them, client-side guards and retry-safe design.
Read →Learn how immutable data differs from mutable data, why it makes aliasing and concurrency safe, what it costs, and when local mutation is still fine.
Read →Learn why Kotlin classes are final by default, how open, override and abstract work, how one class implements many interfaces, and when sealed classes fit.
Read →Learn how input becomes the initial state of a program, how output comes from its final state, and why the boundary between program and world shapes design.
Read →Learn how Kotlin coroutines suspend without blocking threads, how launch, async and await start work, and how scopes give structured concurrency without leaks.
Read →Learn declarative UI in Jetpack Compose: composable functions, Text and Button, Column, Row and Box layouts, why modifier order matters, and previews.
Read →Learn Kotlin read-only and mutable List, Set and Map, how to create and query them, and how filter, map, groupBy, partition, fold and destructuring work.
Read →Learn what Kotlin is, how static typing and null safety catch errors early, and how Kotlin runs on the JVM, as native code and as JavaScript.
Read →Learn how Kotlin nullable types work, and how safe calls, the Elvis operator, the not-null assertion, smart casts, safe casts and let handle null values.
Read →See how Kotlin treats functions as values: lambda syntax, function types, higher-order functions, trailing lambdas, implicit it, receivers and labeled returns.
Read →Learn when architecture layers help or add overhead: the dependency rule, pass-through use cases, leaky abstractions and one-implementation interfaces.
Read →Learn what object allocation costs on the JVM and ART: TLAB bump pointers, object headers and alignment padding, and when hot-loop allocation causes GC jank.
Read →Learn why threads see stale data: CPU caches, store buffers and reordering, the Java Memory Model, happens-before rules, volatile, synchronized and @Volatile.
Read →See how to turn real-world concepts into data structures: essential attributes, types, relationships, choice types, optional fields and a bookstore model.
Read →Weigh the costs of Android modularization: build times, API surfaces, circular dependencies, Gradle overhead, cross-module navigation and when to split.
Read →Learn what val, var and immutability mean in memory: String bytes, in-place mutation, copy-on-write, the String pool, data class copy() and read-only List.
Read →See how names hide details and levels of abstraction keep programs understandable, what makes a good name, and when you must look below an abstraction.
Read →Set up navigation in Jetpack Compose with NavController and NavHost, pass arguments in routes, control the back stack with popUpTo and keep screens decoupled.
Read →Make HTTP calls on Android with Retrofit suspend functions, parse JSON with kotlinx.serialization, check Response status codes and handle network errors.
Read →See why null causes crashes, how nullable and optional types make absence visible, and how to handle missing values with checks, defaults and early failure.
Read →Learn why Android memory leaks happen: object graphs, GC roots, lifetime mismatch, common Activity leaks, how LeakCanary works and when to use WeakReference.
Read →Design an offline-first Android app: Room as source of truth with Flow and Retrofit, optimistic updates, sync strategies, WorkManager and conflict resolution.
Read →Handle partial failures in Android: sealed classes for partial states, Result per operation, Compose error boundaries, offline-first writes and per-step checks.
Read →See how integers, floating-point numbers, booleans and characters work, how bit size sets range and precision, and why overflow and conversions cause bugs.
Read →Android kills background apps to free memory. Learn what survives process death, how SavedStateHandle and rememberSaveable restore state, and how to test it.
Read →Learn to read Android Studio CPU traces: call charts, top-down and bottom-up views, allocation hot spots, plus Perfetto, Baseline Profiles and Macrobenchmark.
Read →Learn why read-modify-write and interleaving cause race conditions on shared state, and how synchronized, atomics, confinement and immutability fix them.
Read →Separate Android performance myths from real wins: object creation on ART, overdraw, flat layouts, main thread IO, image sizing, DiffUtil and Compose stability.
Read →See how repetition runs the same instructions many times, how a termination condition ends a loop, and how accumulation and invariants keep loops correct.
Read →See how an Android Repository hides network and database sources behind an interface, keeps one source of truth and makes ViewModels easy to test with fakes.
Read →Learn how OkHttp timeouts work, why retries need exponential backoff, jitter and a retry budget, which requests are safe to retry, and what circuit breakers do.
Read →Store data locally on Android with Room: define entities, DAOs and the database class, run suspend queries, observe tables with Flow and write migrations.
Read →Compare the five Kotlin scope functions by how they access the object, as this or it, and what they return, then see when to use let, run, with, apply and also.
Read →See how sequential execution works, why each instruction depends on the state left by earlier ones, and how dependencies decide the correct order of your code.
Read →Compare eager Kotlin collections with lazy sequences: how to create them, intermediate and terminal operations, early termination, and when to avoid them.
Read →Learn why Gson reflection is slower than Moshi codegen and kotlinx.serialization, how streaming parsers save memory, and when Protobuf beats JSON on Android.
Read →See what breaks when threads share mutable state: race conditions, data races, lost updates from non-atomic steps, stale values from caches and CPU reordering.
Read →See how a program moves through many states one instruction at a time, how to trace each state transition, and how invariants help you verify code.
Read →See how state drives Jetpack Compose UI: keep values with remember and mutableStateOf, understand recomposition, and hoist state to make composables stateless.
Read →Compare MVVM with many StateFlows and MVI with one state object: consistency, Compose recomposition cost, StateFlow vs SharedFlow, derived state and reducers.
Read →JVM strings are immutable, so each change allocates. See why loop concatenation is quadratic, what Kotlin templates compile to, and when to use StringBuilder.
Read →See how Kotlin coroutines form parent-child trees: scopes set lifetimes, cancellation flows down, failures flow up, and supervisorScope isolates child failures.
Read →See what the suspend modifier means in Kotlin, where you can call them, why suspension frees the thread unlike Thread.sleep, and how calls run in order.
Read →Protect shared data in Kotlin and Java with locks and synchronized blocks, avoid deadlocks with a fixed lock order, and choose between volatile and atomics.
Read →Learn where network time goes: TCP ACKs and slow start, head-of-line blocking in HTTP/1.1 and HTTP/2, QUIC in HTTP/3, OkHttp pooling and mobile latency.
Read →Compare unit and instrumented tests on Android, test ViewModels with fakes, test coroutines with runTest, write Compose UI tests and follow the test pyramid.
Read →Each call pushes a stack frame with parameters, locals and a return address. Learn to read stack traces, why stacks overflow, and how coroutines use the heap.
Read →The Android main thread is a loop over a MessageQueue. Learn how Looper, Handler, Choreographer, HandlerThread, IdleHandler and Dispatchers.Main work with it.
Read →Android renders each frame in measure, layout and draw passes. Learn invalidate vs requestLayout, double taxation in nested weights, RenderThread and overdraw.
Read →See what a thread is, how to create, start and join threads in Kotlin, how threads share memory, when to use ThreadLocal, and why threads cost memory and time.
Read →A thread is a stack, saved registers and a kernel control block. Learn how Linux schedules threads, what they cost, and why delay is cheaper than Thread.sleep.
Read →Every external call needs a timeout. Learn to set OkHttp timeouts, which HTTP errors to retry, and how backoff, jitter, retry budgets and circuit breakers work.
Read →See how Kotlin declares variables with val, var and const val, how type inference works, when to write the type, and how scope and naming keep code clear.
Read →See how an Android ViewModel keeps UI state through configuration changes, exposes it with StateFlow, runs work in viewModelScope and feeds Compose screens.
Read →See how the Android View tree works, which Views and layouts to use, how XML attributes size Views, and how type-safe view binding replaces findViewById.
Read →The GC treats strong, weak, soft and phantom references differently. Learn why SoftReference caches fail on Android and how WeakHashMap and ReferenceQueue work.
Read →Follow one Retrofit call from Kotlin to the server and back: DNS, TCP handshake, TLS 1.3, server time, download, and how OkHttp pooling and HTTP/2 cut latency.
Read →Build a mental model of a program: a description of computation that turns initial state into final state through instructions, shown with a Kotlin example.
Read →See what concurrency is, how it differs from parallelism, why it helps responsiveness and throughput, and why interleaving and race conditions make it hard.
Read →Abstraction has costs. Learn when to skip one-line repositories, pass-through use cases and one-implementation interfaces, and how the Rule of Three helps.
Read →Learn to profile in Android Studio and Perfetto, read flame charts, choose sampling or instrumentation, and see why IO, not algorithms, usually dominates.
Read →Clean Architecture often adds mappers, pass-through use cases and layers to simple Android apps. Learn when it fits, when it fails, and what to use instead.
Read →There are no articles in this category yet.