Skip to content
tezvyn:

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 202

What is the difference between viewModelScope and lifecycleScope?
Android & Kotlin2 min 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.

When would you choose Foreground Service over WorkManager?
Android & Kotlin2 min read

When would you choose Foreground Service over WorkManager?

Tests immediate user-visible work versus deferrable jobs. Strong answers cite a notification-driven use case the user actively expects, like live navigation or a workout. Red flag: claiming WorkManager replaces real-time foreground tasks.

Explain Structured Concurrency in Kotlin Coroutines
Android & Kotlin2 min read

Explain Structured Concurrency in Kotlin Coroutines

Structured concurrency binds coroutines to a scope; parent cancellation propagates to all children, preventing leaks.

Android 12 foreground service restrictions and WorkManager expedited jobs
Android & Kotlin2 min 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.

What is the difference between test and androidTest source sets?
Android & Kotlin2 min read

What is the difference between test and androidTest source sets?

Say test runs on the JVM for unit tests mocking Android classes, while androidTest runs on device for instrumented tests.

Why mock a Repository dependency in a ViewModel unit test?
Android & Kotlin2 min 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.

Unit test a ViewModel exposing StateFlow in a local JVM test
Android & Kotlin2 min 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.

Explain integration tests and isolate Room DAO tests
Android & Kotlin2 min 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.

Mock vs Fake test doubles: when to use a Fake Repository?
Android & Kotlin2 min read

Mock vs Fake test doubles: when to use a Fake Repository?

Tests if you know a Fake is a working lightweight implementation while a Mock verifies interactions. Good answers define Fake as in-memory with real logic, Mock as expectation-based, and choose a Repository Fake when many tests need reusable state.

How do you test a Compose click and verify state change?
Android & Kotlin2 min read

How do you test a Compose click and verify state change?

This tests Compose semantics and interaction-to-assertion flow. Mention ComposeTestRule, onNodeWithTag, performClick, and assert on the changed node with assertIsDisplayed or assertTextEquals.

How would you implement and register a custom IdlingResource?
Android & Kotlin2 min read

How would you implement and register a custom IdlingResource?

Implement the three IdlingResource methods with an atomic counter; register via IdlingRegistry in setup and unregister in teardown.

What is the role of TestDispatcher and runTest in coroutine testing?
Android & Kotlin2 min read

What is the role of TestDispatcher and runTest in coroutine testing?

This tests coroutine test infrastructure and virtual time control. A great answer says runTest installs a TestDispatcher and TestScope, skips delays automatically, and exposes advanceTimeBy to test timeouts instantly.

What is Android Test Orchestrator and how does it isolate tests?
Android & Kotlin2 min read

What is Android Test Orchestrator and how does it isolate tests?

Tests process-level isolation in Android UI suites. A strong answer says it runs each test in its own Instrumentation process, stopping crashes or leaked state from cascading, and notes slower startup.

What is an Android memory leak? Give a Context example and fix.
Android & Kotlin2 min read

What is an Android memory leak? Give a Context example and fix.

Tests understanding of Activity Context retention preventing GC. A strong answer defines a leak as unreachable objects, gives a static singleton example, names LeakCanary, and fixes it with Application Context. Red flag: blaming GC or suggesting System.gc().

What is overdraw in Android UI and how do you reduce it?
Android & Kotlin2 min read

What is overdraw in Android UI and how do you reduce it?

This tests GPU fill awareness. A strong answer defines overdraw as redrawing pixels repeatedly, names Debug GPU Overdraw's color overlay, and offers fixes: remove unnecessary backgrounds and flatten hierarchies. Red flag: confusing this with CPU layout issues.

Why avoid plain SharedPreferences for secrets and what to use?
Android & Kotlin2 min read

Why avoid plain SharedPreferences for secrets and what to use?

Tests data-at-rest security awareness. A strong answer notes plain SharedPreferences writes unencrypted XML that rooted users or backups expose, then names EncryptedSharedPreferences with Android Keystore.

Diagnose Android UI jank using Android Studio's Profiler
Android & Kotlin2 min read

Diagnose Android UI jank using Android Studio's Profiler

Start with CPU Profiler for traces over 16ms and main thread blocking; check Memory Profiler for GC.

Explain cold, warm, and hot app startups and three cold-start optimizations
Android & Kotlin2 min read

Explain cold, warm, and hot app startups and three cold-start optimizations

Cold means no process; warm means process lives but activity recreates; hot means activity resumes. Three fixes: lazy-load deps, trim Application.onCreate, defer blocking I/O.

What is certificate pinning and what are its trade-offs?
Android & Kotlin2 min read

What is certificate pinning and what are its trade-offs?

Pinning hardcodes a server key to block rogue CA MITM; trade-offs are breakage on cert rotation and forced updates.

Use Android Keystore to secure a database encryption key
Android & Kotlin2 min read

Use Android Keystore to secure a database encryption key

Tests Android Keystore key generation and hardware trust boundaries. Strong answers: KeyGenParameterSpec with AES/GCM, TEE vs StrongBox isolation, setIsStrongBoxBacked on API 28+ with fallback, wrapping the database key. Red flag: claims Keystore encrypts DBs.