tezvyn:

📱Mobile Dev

Mobile app development across platforms

351 bites

Android & Kotlin30 sec read

Explain integration tests and isolate Room DAO tests

Tests integration vs unit testing and Room isolation. Outline: verify real DAO-to-DB interaction with Room.inMemoryDatabaseBuilder; reset state by closing and recreating the DB in @After. Red flag: mocking the DAO or using an on-disk database.

Android & Kotlin30 sec read

Unit test a ViewModel exposing StateFlow in a local JVM test

Tests coroutine hygiene and flow collection strategy. A strong answer covers injecting a TestDispatcher, using runTest, collecting emissions in a background scope, and asserting states.

Android & Kotlin32 sec read

Why mock a Repository dependency in a ViewModel unit test?

This tests your grasp of test isolation. A great answer says mocking eliminates real database or network dependencies so you can verify ViewModel state changes in isolation. A red flag is insisting on using the real Repository inside the unit test.

Android & Kotlin30 sec read

What is the difference between test and androidTest source sets?

This tests understanding of test environments. OUTLINE: Say test runs on the JVM for unit tests mocking Android classes, while androidTest runs on device for instrumented tests. RED FLAG: Saying both need a device or treating them interchangeably.

Android & Kotlin30 sec read

Android 12 foreground service restrictions and WorkManager expedited jobs

Tests Android 12 background-start limits. A great answer covers: the API 31 ban on background FGS starts, BOOT_COMPLETED exceptions, and WorkManager setExpedited with out-of-quota fallback. Red flag: starting an FGS in a BroadcastReceiver ignoring quota.

Android & Kotlin30 sec read

Explain Structured Concurrency in Kotlin Coroutines

WHAT IT TESTS: your grasp of Kotlin coroutine parent-child scope hierarchies. ANSWER OUTLINE: structured concurrency binds coroutines to a scope; parent cancellation propagates to all children, preventing leaks. RED FLAG: calling them unmanaged threads.

Android & Kotlin30 sec read

What is the difference between viewModelScope and lifecycleScope?

This tests scope ownership across configuration changes. viewModelScope survives rotation because it lives in ViewModel, while lifecycleScope dies with UI; use former for logic and latter for UI tasks. Never launch data loads in lifecycleScope.

Android & Kotlin30 sec read

How do you make a network request in an Activity using coroutines?

This tests main thread safety and coroutine dispatchers. A strong answer cites NetworkOnMainThreadException, uses lifecycleScope, and switches to Dispatchers.IO. Red flag: suggesting Dispatchers.Main for the network call or omitting the exception entirely.

Android & Kotlin30 sec read

How would you access a Hilt dependency in a non-injectable ContentProvider?

Tests Hilt's escape hatch for framework classes. Strong answer: define an EntryPoint in SingletonComponent, expose the dependency, and retrieve it with EntryPointAccessors.fromApplication. Red flag: field injection or manual static singletons.

Android & Kotlin30 sec read

How do you inject two different OkHttpClient instances with Hilt?

Tests Hilt qualifiers for same-type bindings. Answer: define a custom @Qualifier (or @Named), annotate two @Provides methods and the injection site. Red flag: manual client creation or subclassing OkHttpClient instead of qualifying the binding.

Android & Kotlin30 sec read

How do you inject UserRepository into a ViewModel with Hilt?

Tests Hilt constructor injection for classes you own. Annotate UserRepository's constructor with @Inject so Hilt auto-provides it to consumers like a @HiltViewModel. Red flag: using a @Provides module for a class you control.

Android & Kotlin30 sec 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 & Kotlin30 sec 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 & Kotlin30 sec 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 & Kotlin30 sec 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.

Android & Kotlin30 sec 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.

Android & Kotlin30 sec 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.

Android & Kotlin30 sec 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.

Android & Kotlin30 sec 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.

Android & Kotlin30 sec 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.