Intermediate everything in Android & Kotlin, page 3

Explain Hilt scoping: @Singleton vs @ActivityRetainedScoped
Tests Hilt component lifecycles. Answer: @Singleton lives for the app process; @ActivityRetainedScoped survives config changes via ActivityRetainedComponent but dies when the activity finishes.

How do you upload a file with text data in Retrofit?
Tests multipart uploads versus JSON bodies. Strong answer: @Multipart, @POST, @Part; file as MultipartBody.Part and text as RequestBody; avoid @Field. Red flag: suggesting @Body with a data class.

How do you differentiate network and server errors in suspend functions?
Catch IOException for connectivity and HttpException for HTTP errors; wrap in a sealed Result.

Preferences vs Proto DataStore: when is Proto significantly better?
This tests type safety and schema trade-offs. A strong answer contrasts Preferences key-value pairs with Proto typed protobuf schemas, then names nested settings or migration needs as the Proto win. A red flag is recommending Proto for a single boolean.

Model a Room one-to-many Playlist-to-Song relationship
Tests Room relational modeling. Strong answer: Song foreign key, @Embedded Playlist with @Relation to List<Song>, DAO wrapped in @Transaction. Red flag: embedding songs in Playlist or skipping @Transaction, which causes N+1 queries.

How do you add a non-null column with a default in Room?
Bump version; run ALTER TABLE ADD COLUMN with NOT NULL DEFAULT in a Migration; register via addMigrations.

Explain the purpose of a UseCase and how it fits into MVVM
UseCases encapsulate single business rules between ViewModel and Repository, keeping ViewModels lean and Repositories focused on data.

How do you share a ViewModel across multiple Fragments?
Tests ViewModel scoping and Fragment communication. A strong answer names activityViewModels or navGraphViewModels, warns about Activity memory retention and hidden coupling, and suggests a parent Fragment or data flow alternative.

How would you use a nested navigation graph for a login flow?
Tests modular navigation scoping. Strong answers group the three screens under a nested graph with its own start destination, noting encapsulation and reusability.

Why is LiveData<Boolean> problematic for one-time ViewModel events?
State is not events; suggest an Event wrapper with a consumed flag, or SharedFlow or Channel with no replay.

How do you display a large list efficiently in Jetpack Compose?
This tests understanding of Compose lazy versus eager layout. A strong answer names LazyColumn or LazyRow, notes visible-only composition, and contrasts Column which lays out everything upfront.

Which side-effect handler for a one-time coroutine on composition entry?
Tests Compose side-effect API boundaries. Answer: LaunchedEffect(Unit); it runs once and auto-cancels on exit. Contrast with rememberCoroutineScope for user-triggered callbacks. Red flag: picking SideEffect or rememberCoroutineScope and missing cancellation.

Describe state hoisting and its benefits in Compose
Move state to the caller, pass value and event lambda down, keep them stateless.

Explain Jetpack Compose recomposition, its triggers, and optimizations.
This tests grasp of Compose's reactive model. A strong answer defines recomposition as recomputing composables when state changes, notes State triggers it, and explains Compose skips unchanged subtrees via smart tracking.
How does ConstraintLayout enable flat responsive UIs with chains and barriers?
It tests constraint-based positioning and flat hierarchy performance. A strong answer covers relative constraints replacing nested layouts, chains for distributing groups, and barriers for dynamic alignment to extreme edges.

Difference between Style and Theme, and how ?attr/ resolves vs @color/
Probes Android resource indirection depth. A style targets one View; a theme targets a Context. ?attr/ resolves dynamically against the current theme at runtime, but @color/ is a static compile-time constant. Red flag: saying both resolve the same way.

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.

When and why use a Foreground Service on API 26+?
Tests background execution limits. Good answer: use for noticeable long-running work; declare FOREGROUND_SERVICE, show a notification, and respect API 26 background start limits. Red flag: calling it invisible work or omitting the notification.

Describe the back stack for A to B to C with singleTask
Tests singleTask plus taskAffinity, not rote memorization. With default affinity, C sits atop B in the same task; if C already existed, the system clears B and delivers onNewIntent. Red flag: claiming singleTask always spawns a new task.

What is ADB? Describe two common commands and what they accomplish.
This tests command-line debugging fluency. Define ADB as a client-server bridge, then give two commands such as adb install for APK deployment and adb logcat for streaming device logs. Red flag: calling it the Android Studio debugger or omitting the daemon.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles