How do you handle network calls and errors in a mobile app?
What the interviewer wants to hear
- Run calls off the main thread with async/await or coroutines
- Show loading, success, empty and error states
- Handle no network, timeouts and server errors differently
- Retry with backoff where safe; let the user retry
- Cache data so the app is useful offline
Model answer
I always run network calls off the main thread, using coroutines with Retrofit or Ktor on Android, async/await with URLSession on iOS, or async functions in Flutter and React Native. Each screen has clear UI states: loading, success, empty and error. I treat errors differently: no internet shows a friendly offline message, a timeout offers a retry, a 401 sends the user to login, and a 5xx shows a generic error and is logged to monitoring. For safe requests I retry automatically with exponential backoff. I set sensible timeouts, and I cache the last good data locally so the screen still shows something when offline. I never show raw error messages or stack traces to users.
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?
- Explain the lifecycle of a mobile app screen. Why does it matter?
- 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?