All bites
The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.
4330 bites
Page 200

How do you pass data between Fragments with Jetpack Navigation?
Tests knowledge of modern, type-safe argument passing. A good answer defines the argument in the nav graph XML, uses the Safe Args plugin to generate Directions/Args classes, navigates with the action, and retrieves the data in the destination via `by…

How to pass data between Fragments with Jetpack Navigation?
This tests your knowledge of type-safe argument passing in Jetpack Navigation. A good answer defines the argument in XML, uses the Safe Args plugin to generate code, passes data via the Directions class, and retrieves it with the Args class.

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.

Why is LiveData<Boolean> bad for one-time ViewModel events?
Tests if you know LiveData holds state, not events. A good answer explains that LiveData re-emits on configuration changes, causing repeated events. The solution is to model events as part of the UI state and consume them.

Why is `LiveData<Boolean>` bad for one-time ViewModel events?
This tests your grasp of state vs. events. A LiveData<Boolean> is state; it re-triggers on rotation. Instead, expose events via a StateFlow and have the UI call an eventConsumed() function on the ViewModel to maintain unidirectional data flow.

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.

How to use a nested navigation graph for a login flow?
Tests your ability to structure complex UI flows using Navigation Component. A great answer defines a separate login graph XML, includes it in the main graph, and navigates to the graph's ID. This encapsulates the flow, making it reusable.

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 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().

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.

Explain the purpose of a UseCase or Interactor layer
Tests your grasp of separation of concerns. A great answer defines a UseCase as a single, reusable business operation that sits between the ViewModel and Repository. It keeps other layers clean and focused.

How would you architect two source Flows from ViewModel to data layer?
This tests merging parallel async streams into one reactive state. A strong answer uses combine on two cold repository Flows, exposes one UI state Flow from the ViewModel, and maps failures to error states. Red flag: using two coroutines mutating shared state.

Combine two network sources using Coroutines and Flow
Tests your grasp of async data combination and state management. A good answer uses Flow.combine in a ViewModel, fed by a Repository, emitting a sealed class for UI state (Loading, Success, Error). A red flag is trying to combine state in the UI layer itself.

How do you navigate between feature modules without direct dependencies?
This tests architectural decoupling in multi-module Android apps. A great answer describes a shared navigation contract or deep-link router that lets features stay independent. Recommending direct Gradle dependencies between features is a major red flag.

Navigate between feature modules without direct dependencies?
Tests dependency inversion in modular apps. Answer by defining navigation interfaces in a shared module, implementing them in the :app module, and using DI to connect them. A red flag is suggesting direct module dependencies or using reflection for navigation.

How would you architect state-driven UI with ViewModel and Compose?
Tests unidirectional data flow and state hoisting. Model screen state as an immutable data class, expose StateFlow from ViewModel, and collect it in Compose so events flow up and state down. Red flag: exposing mutable state or putting logic in Composables.

What are Room's three main components and their functions?
Tests whether you know Room's architectural layers. Name the three: Database holds config and is the access point; Entity represents a table schema; DAO defines SQL operations. Red flag: confusing DAOs with Repositories or claiming Room is a full ORM.

Why choose DataStore over SharedPreferences for a toggle?
This tests your grasp of modern Android storage safety beyond syntax. A strong answer names DataStore's async coroutines API, type safety, transactions, and migration support. A red flag is claiming SharedPreferences is simpler while ignoring ANR risk.

How do you define a Room table for a Kotlin data class?
Tests your grasp of the minimum Room entity contract. A strong answer cites Entity and PrimaryKey, notes Kotlin defaults work out of the box, and mentions ColumnInfo for renaming.

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.