More in Android & Kotlin — page 3

Purpose of Android app signing and keystore contents
WHAT IT TESTS: App identity on Android. ANSWER OUTLINE: Signing proves authorship and integrity, enables same-key updates, and binds app identity; a keystore holds private keys and certificates.

How would you use Perfetto and Trace.beginSection to find a non-obvious bottleneck?
Tests correlation beyond CPU sampling. Covers coarse Trace.beginSection to limit 1-10us overhead, recording app ATrace with CPU/scheduling tracks, and correlating slices against scheduler latency. Red flag: omitting overhead or ignoring Perfetto SQL queries.

Explain generational GC in ART and why onDraw must avoid allocations
WHAT IT TESTS: ART generational GC and onDraw allocation hazards. ANSWER OUTLINE: Covers young-gen nursery, mark-sweep fallback, and why a 5-10ms GC pause misses 16ms frame deadline. RED FLAG: Blaming GC without linking allocation to frame timing.

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.

What is certificate pinning and what are its trade-offs?
WHAT IT TESTS: Understanding TLS trust chain attacks beyond HTTPS. ANSWER OUTLINE: Pinning hardcodes a server key to block rogue CA MITM; trade-offs are breakage on cert rotation and forced updates.

Explain cold, warm, and hot app startups and three cold-start optimizations
WHAT IT TESTS: App startup modes and tuning tactics. ANSWER OUTLINE: 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.

Diagnose Android UI jank using Android Studio's Profiler
WHAT IT TESTS: Isolating frame drops to main thread work or GC via Android Studio Profiler. ANSWER OUTLINE: Start with CPU Profiler for traces over 16ms and main thread blocking; check Memory Profiler for GC. RED FLAG: Using Logcat alone or blaming hardware.

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.

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.

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

How would you implement and register a custom IdlingResource?
WHAT IT TESTS: Whether you know Espresso's async contract. ANSWER OUTLINE: Implement the three IdlingResource methods with an atomic counter; register via IdlingRegistry in setup and unregister in teardown. RED FLAG: Suggesting Thread.sleep or polling loops.

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.

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.

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.

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.

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.

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