Android Developer interview question
How do you handle networking on Android?
Android networking needs typed API contracts, timeouts, cancellation, retry only for transient idempotent work, mapped errors, authentication refresh, secure transport, and repository-level caching or persistence.
Direct answer
What a strong answer covers
How it works
Networking on Android sits behind a repository so the UI never sees HTTP. Retrofit or Ktor with a typed API and a serialiser gives compile-time contracts; OkHttp interceptors add authentication, logging in debug builds, and token refresh with a single-flight guard so ten parallel 401s produce one refresh. Timeouts are explicit, calls are cancelled with the coroutine that started them, retries are limited to idempotent requests and transient failures with backoff, errors are mapped to a sealed result the UI can render, and responses that must survive offline go through the local database.
Example
A feed screen calls repository.loadFeed(), which returns cached rows from Room immediately and triggers a network refresh; the Authenticator refreshes the access token once when it expires and replays the failed request, and a 5xx from the API surfaces as a retry banner while a 422 shows the validation message from the response body.
Common mistakes
- Making network calls directly from a composable or Activity and losing them on rotation.
- Retrying every failure including POSTs that already succeeded on the server.
- Disabling certificate validation in a debug build and shipping it by accident.
A useful answer structure
Answer from your own work.
Do not memorise a script: use only examples you can explain honestly in follow-up questions.
Open the desktop workspace and rehearse a clear answer in your own words.