Lifecycle
49 bites tagged Lifecycle — interview questions with model answers, and 60-second explainers.
Static vs dynamic BroadcastReceiver registration and modern Android implications
Tests background limits, lifecycle coupling. Static manifest receivers survive app death but API 26 blocks most implicit broadcasts; dynamic receivers run with the context and must be unregistered. Red flag: static registration handles all implicit broadcasts.
How do you share a ViewModel between Fragments?
Tests your understanding of ViewModel lifecycle scoping beyond a single screen. To share, scope the ViewModel to the parent Activity or a navigation graph using `activityViewModels()` or `navGraphViewModels()`.
What is a Jetpack ViewModel and the problem it solves?
This tests your understanding of lifecycle-aware state preservation. A good answer explains that ViewModels survive configuration changes (like rotation) to hold UI data, separating it from the transient UI controller.
Bound Service Lifecycle with Config Changes & Multiple Clients
Tests your grasp of bound Service lifecycles. Explain that with BIND_AUTO_CREATE, the Service survives an Activity's config change recreation. It's only destroyed after the *last* client unbinds. A red flag is assuming the Service dies with the first client.
Explain app restoration after Android process death
Tests your grasp of process death vs. configuration changes. A good answer explains that the entire app process is recreated, starting with onCreate, and state must be restored from the SavedStateHandle.
How does a ViewModel survive configuration changes?
Tests understanding of lifecycle-aware components. ViewModels are retained by a ViewModelStore owned by the Activity/Fragment, which survives configuration changes. The ViewModel is cleared only when its scope is permanently finished.
Started vs. Bound Services: Differences and Use Cases
Tests Android component lifecycle and IPC knowledge. A good answer defines lifecycle control (start vs. bind), communication (one-way vs. two-way IBinder), and gives clear use cases. A red flag is assuming services run on a background thread by default.
Trace an Activity's lifecycle when a user navigates away and returns
This tests your understanding of resource management and state preservation, not just memorization. A great answer traces onPause -> onStop when leaving, and onRestart -> onStart -> onResume when returning, explaining what happens in each.
lateinit var vs. val by lazy in Android
Tests your grasp of Kotlin's non-nullable property initialization. Define `lateinit` (mutable, framework-init) vs. `lazy` (immutable, deferred-init). Use `lateinit` for Views in `onCreate` and `lazy` for expensive objects. Red flag: confusing their mutability.
What problem does Jetpack ViewModel solve during configuration changes?
This tests your understanding of state loss during configuration changes. A good answer explains that Activities are destroyed on rotation, and ViewModel survives this event, preserving UI state.
How does Android manage a ContentProvider's lifecycle during a query?
This tests your understanding of Android IPC and component lifecycles. Explain how ContentResolver uses a URI to have the system instantiate the provider in its own process.
Bound Service Lifecycle: Config Changes and Multiple Clients
Tests deep knowledge of bound service lifecycles. A config change causes an unbind/rebind cycle, recreating the service. With multiple clients, the service isn't destroyed until the last one unbinds. Red flag: assuming the service survives the config change.
Handle Android Process Death vs. Configuration Changes
Tests your grasp of Android's lifecycle for state restoration. A good answer explains that `onCreate(savedInstanceState)` is called in both cases, but process death recreates everything. Use `ViewModel` with `SavedStateHandle`.
How does a ViewModel survive configuration changes?
Tests understanding of ViewModel's scope, separate from the Activity lifecycle. A ViewModel is retained by a ViewModelStore, which persists across configuration changes. The new Activity instance then reconnects to the same ViewModel.
Started vs. Bound Services: Differences and Use Cases
Tests your grasp of Android component lifecycles. A strong answer defines each by its lifecycle control (who starts/stops it) and communication pattern (fire-and-forget vs. client-server), then gives distinct use cases.
Describe the Android Activity lifecycle when navigating away and back
Tests understanding of resource management via lifecycle callbacks. A good answer traces onPause -> onStop -> onRestart -> onStart -> onResume, explaining what work happens in each.
lateinit var vs. val by lazy in Android
Tests your grasp of Kotlin property initialization and its lifecycle implications. A good answer contrasts mutability (var/val), initialization timing, and thread safety.
Svelte Lifecycle: Mount, Destroy, and Tick
Svelte 5 simplifies the component lifecycle to just two events: creation (`onMount`) and destruction (`onDestroy`). Use `onMount` for DOM setup and return a cleanup function from it. The cleanup only works if the main callback is synchronous, not async.
Angular Component Lifecycle Hooks
Angular's lifecycle hooks are callbacks for a component's life events: creation, updates, and destruction. Use ngOnInit for one-time setup after inputs are ready, and ngOnChanges to react to input changes. The footgun: don't use the constructor for setup.
React Navigation Lifecycle: Screens Don't Unmount
Unlike the web, React Native screens don't unmount when you navigate away; they stay mounted to preserve state. This means a standard `useEffect` only runs once. To run code when a screen is shown, you must listen for the `focus` event.
Product Sunsetting: Retiring Products Gracefully
Product sunsetting is the managed process of retiring a product to free up resources. It's used when a product is no longer profitable or strategically relevant. The biggest footgun is a sudden shutdown without a clear migration path, which alienates users.
UISceneDelegate: Managing Your App's UI Instances
Think of SceneDelegate as the lifecycle manager for a single window of your app's UI. It's essential for multi-window iPad apps, handling when a scene connects, disconnects, or changes state.
Flutter's State Lifecycle: From Creation to Disposal
A Flutter State object outlives its widget configuration. The framework manages its journey from creation (`initState`) to permanent removal (`dispose`), calling methods like `build` along the way. This governs all `StatefulWidget`s.
Android's Activity Lifecycle: A Screen's Journey
Think of an Activity's lifecycle as a stage play's script. Methods like onCreate() and onPause() are cues for your app screen to set up, appear, or hide. This manages state during interruptions like phone calls.
Get Lifecycle bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.