tezvyn:

📱Mobile Dev

Mobile app development across platforms

1323 bites

More in Mobile Dev — page 28

What is Dependency Injection and Hilt's benefit over manual instantiation?
Android & Kotlin2 min read

What is Dependency Injection and Hilt's benefit over manual instantiation?

Tests your grasp of inversion of control and why frameworks matter. A good answer defines DI as supplying dependencies from outside, states Hilt automates object graph creation and scoping, and notes manual instantiation scatters construction logic.

Android & Kotlin2 min read

Configure OkHttp Cache for Retrofit and force network requests

This tests HTTP caching semantics in mobile networking. A strong answer covers Cache setup with a 50 MiB directory, server Cache-Control driving expiration, and CacheControl.FORCE_NETWORK to bypass.

Android & Kotlin2 min read

Parse polymorphic media JSON with Kotlin sealed classes and custom serializers

WHAT IT TESTS: Polymorphic deserialization with Kotlin sealed classes. ANSWER OUTLINE: Sealed Media with Image and Video; use Moshi Factory or kotlinx.serialization keyed on the type field. RED FLAG: Manual JSONObject branching or reflection-based parsing.

How do you upload a file with text data in Retrofit?
Android & Kotlin2 min read

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?
Android & Kotlin2 min read

How do you differentiate network and server errors in suspend functions?

WHAT IT TESTS: Structured error handling in coroutines and mapping exceptions to recovery. ANSWER OUTLINE: Catch IOException for connectivity and HttpException for HTTP errors; wrap in a sealed Result. RED FLAG: Catching Exception or exposing raw errors to UI.

Android & Kotlin2 min read

How do you configure Moshi or Kotlinx.serialization for JSON key mismatches?

This tests library-specific field-mapping annotations. For Kotlinx.serialization use @SerialName with the JSON key; for Moshi use @Json with the name parameter. A red flag is confusing the two or using manual mapping instead of the built-in decorator.

How would you implement a robust offline-first repository?
Android & Kotlin2 min read

How would you implement a robust offline-first repository?

Tests single-source-of-truth discipline and network-local sync. Outline a Room repository with Flow, background refresh, disk persistence, immediate local emission, and conflict resolution with retry.

Room DAO: Flow<List<User>> vs suspend fun getUsers(): List<User>
Android & Kotlin2 min read

Room DAO: Flow<List<User>> vs suspend fun getUsers(): List<User>

This tests reactivity versus one-shot queries in Room and coroutines. Flow emits on every table change on Room's dispatcher, while suspend returns a single snapshot requiring manual refresh.

Preferences vs Proto DataStore: when is Proto significantly better?
Android & Kotlin2 min read

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
Android & Kotlin2 min read

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?
Android & Kotlin2 min read

How do you add a non-null column with a default in Room?

WHAT IT TESTS: SQLite ALTER TABLE semantics and Room Migration wiring. ANSWER OUTLINE: Bump version; run ALTER TABLE ADD COLUMN with NOT NULL DEFAULT in a Migration; register via addMigrations. RED FLAG: Dropping tables or omitting DEFAULT on existing rows.

How do you define a Room table for a Kotlin data class?
Android & Kotlin2 min read

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.

Why choose DataStore over SharedPreferences for a toggle?
Android & Kotlin2 min read

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.

What are Room's three main components and their functions?
Android & Kotlin2 min read

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.

How would you architect state-driven UI with ViewModel and Compose?
Android & Kotlin2 min read

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.

How do you navigate between feature modules without direct dependencies?
Android & Kotlin2 min read

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.

How would you architect two source Flows from ViewModel to data layer?
Android & Kotlin2 min read

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.

Explain the purpose of a UseCase and how it fits into MVVM
Android & Kotlin2 min read

Explain the purpose of a UseCase and how it fits into MVVM

WHAT IT TESTS: Separation of concerns beyond basic MVVM. ANSWER OUTLINE: 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?
Android & Kotlin2 min read

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?
Android & Kotlin2 min read

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.