More in Mobile Dev — page 30

Describe the back stack for A to B to C with singleTask
Tests singleTask plus taskAffinity, not rote memorization. With default affinity, C sits atop B in the same task; if C already existed, the system clears B and delivers onNewIntent. Red flag: claiming singleTask always spawns a new task.

Activity rotation: what happens to EditText text?
WHAT IT TESTS: Activity lifecycle and state on rotation. ANSWER OUTLINE: Rotation destroys and recreates the Activity; EditText auto-saves text if it has an ID, else onSaveInstanceState or SavedStateHandle. RED FLAG: Always lost, or using SharedPreferences.

Describe the Android Activity lifecycle and callback order
WHAT IT TESTS: Activity callback order during user navigation. ANSWER OUTLINE: Away calls onPause then onStop; back calls onRestart, onStart, onResume; onCreate only runs after destruction. RED FLAG: Claiming onDestroy or onCreate run on every away-and-back.
How do you manage API keys across Gradle build variants securely?
WHAT IT TESTS: Gradle secret injection per build variant without committing credentials. ANSWER OUTLINE: Gitignore a properties file, load it in build.gradle, map secrets to BuildConfig or manifest placeholders by flavor, and commit safe defaults.

Which Android Studio Profiler tool diagnoses high memory usage and leaks?
WHAT IT TESTS: Memory Profiler expertise and systematic leak diagnosis. ANSWER OUTLINE: Heap dump, check retained size for leaked Activities, trace reference chains to root retainer. RED FLAG: Naming CPU profiler or saying "look for big objects."

What is ADB? Describe two common commands and what they accomplish.
This tests command-line debugging fluency. Define ADB as a client-server bridge, then give two commands such as adb install for APK deployment and adb logcat for streaming device logs. Red flag: calling it the Android Studio debugger or omitting the daemon.

Which Android Studio tool inspects view hierarchy and what does it show?
Tests practical knowledge of runtime UI debugging tools. A strong answer names Layout Inspector, cites live view hierarchy with bounds and attributes, and distinguishes it from the static Layout Editor. Red flag: citing Logcat or the preview pane instead.

Explain what a Gradle product flavor is and give a free vs pro example
Tests understanding of build-variant dimensions beyond build types. A strong answer defines flavorDimensions, sets free and pro applicationIdSuffix values, and explains variant generation. Red flag: conflating flavors with build types or manual APK renaming.

App crash: debug with Logcat and breakpoints in Android Studio
This tests systematic debugging and Android Studio fluency. A strong answer reproduces the crash, filters Logcat for the fatal exception, sets a breakpoint on the offending frame, and inspects variables.

What is the res directory and how do you use orientation qualifiers?
WHAT IT TESTS: Android's declarative resource system and runtime configuration adaptation. ANSWER OUTLINE: res/ holds non-code assets; create layout-port/ and layout-land/ with identical XML filenames for automatic framework selection.

What is the difference between project-level and module-level build.gradle?
WHAT IT TESTS: Gradle scope in multi-module Android projects. ANSWER OUTLINE: Project level sets plugin repos and shared versions; module level sets dependencies, build types, and flavors. RED FLAG: Claiming both files do the same thing or misplacing plugins.

What is AndroidManifest.xml and what key elements does it declare?
This tests your grasp of the system-app contract. Good answers cover component registration, permissions, and build metadata like package name and target SDK. A red flag is omitting install-time system discovery.

How would you implement a type-safe Kotlin DSL for a UI Form?
Tests Kotlin DSL scoping with lambda receivers and extensions. Strong answers sketch a Form builder using initTag, explain T.() -> Unit implicit this for child elements, and add DslMarker to block scope leaks. Red flag: describing it as simple method chaining.

What is a reified type parameter in Kotlin?
Tests JVM type erasure and inline function mechanics. Strong answer: reified preserves generic types at runtime via inline expansion, enabling is T checks without Class<T> passing. Red flag: claiming reified works without inline or outside functions.

Describe coroutine cancellation mechanics and cooperative suspend functions
Tests cooperative cancellation mechanics. cancel() sets a Job to cancelling; suspend functions check this at suspension points and throw CancellationException, yet a tight non-suspending loop never checks and keeps running.
How do buffer, conflate, and collectLatest manage Kotlin Flow backpressure?
WHAT IT TESTS: Coroutine flow control and suspension-vs-dropping tradeoffs. ANSWER OUTLINE: Backpressure is fast emit vs slow collect; buffer() suspends the producer when full, conflate() drops stale values, and collectLatest() cancels active collection to…

Explain Kotlin's declaration-site variance with in and out
WHAT IT TESTS: Understanding declaration-site variance versus wildcards. ANSWER OUTLINE: out T means covariant producer (read), in T means contravariant consumer (write), removing wildcard noise. RED FLAG: Confusing in/out with bounds or claiming immutability.

What is a CoroutineDispatcher and when to use Default versus IO?
This tests thread pool selection and the CPU versus IO distinction. A strong answer maps CoroutineDispatcher to the thread pool, Default to CPU work, IO to blocking IO, and Main to the UI thread.

Hot vs cold Kotlin Flows and StateFlow use case
Tests grasp of flow lifecycle and collector behavior. A strong answer contrasts cold Flows, which restart per collector, with hot StateFlows broadcasting to all observers. Red flag: using Flow for UI state without citing config changes or initial value.

How does Structured Concurrency handle cancellations and exceptions?
This tests scope-bound lifecycle management preventing leaks. Cover scope cancellation cascading to children, exceptions propagating up to cancel siblings, and launch or async requiring a scope. A red flag is treating coroutines as fire-and-forget threads.