Explain the lifecycle of a mobile app screen. Why does it matter?
What the interviewer wants to hear
- Screens move through created, started/visible, resumed/active, paused, stopped, destroyed
- Release resources like camera or sensors when paused or stopped
- The OS can kill a backgrounded app
- Save state so the user can continue where they left off
- Start and stop observing data at the right time
Model answer
A screen goes through states as the user uses the app. On Android, an Activity goes through onCreate, onStart and onResume when it opens, and onPause, onStop and onDestroy when it leaves. iOS and SwiftUI have similar events like onAppear and scene phases for active, inactive and background. It matters because phones have limited resources. I must stop things like the camera, location updates or video when the screen is not visible, otherwise I waste battery. The OS can also kill the app while it is in the background, so I save important state, like form input, and restore it when the user returns. Lifecycle-aware tools, like collecting flows with repeatOnLifecycle, help do this correctly.
Can you answer it under time pressure?
Take a timed easy round and get scored on every answer.
More easy Mobile App Developer questions
- What is the difference between native and cross-platform mobile development? When would you choose each?
- How do you handle network calls and errors in a mobile app?
- What is MVVM and why is it used in mobile apps?
- How do push notifications work in a mobile app?
- How do you run slow work like network calls or database reads in a mobile app without freezing the UI?
- What options do you have for storing data on the device, and how do you choose between them?
- How do you request runtime permissions like camera or location, and what do you do when the user says no?
- How do you make your app look good on different screen sizes, orientations and font sizes?
- What is the difference between declarative UI (Compose, SwiftUI, Flutter, React Native) and the older imperative style?