© Interview RuntimeThis content is copyright. Copying is disabled; you may quote a short excerpt with a link to the page.

Android mock interview, a 60-minute senior practice round with follow-ups

A senior Android practice round you can run with a colleague or alone, built on 1 saved-items feature, a cancellation exercise, 1 changed requirement and a levelled rubric.

Engraving of a sand hourglass beside a small electric relay switch on a workbench.

In short

  • A mock round works best when it starts from 1 feature whose promise you can state and test.
  • Cancellation is part of coroutine control flow, so a catch-all handler must not turn it into a failed save.
  • Give each state an owner that matches its lifetime. Temporary UI, restorable UI and durable data are 3 different owners.
  • A lost response has an uncertain outcome, so retry only with a defined operation identity.
  • Score each dimension against written level descriptors and end with 1 repair target small enough to repeat tomorrow.

The user taps Save. The server accepts the change. The response never reaches the phone.

Then Android kills the process.

When the app opens again, what does it know?

“We use Room and WorkManager” names 2 useful tools. It leaves the important questions open. What was stored, did the operation already happen, and can a retry repeat it?

This Android mock interview uses a saved-items feature to connect Kotlin cancellation, Compose state, lifecycle and recovery. It is a 60-minute diagnostic rehearsal for experienced engineers. It is not an actual company's interview script, and the condensed format is not a claim that employers test all these areas in 1 round.

Run it with a colleague or record yourself. Keep the answers hidden until you attempt each prompt. Every block has the same shape. A candidate prompt, a weak answer, a reasoned answer, then a follow-up that changes 1 constraint.

Prepare an environment that already works

Use an existing Android project or a Kotlin test project for the cancellation exercise. You can explain the UI and persistence sections on paper, because building a complete app is outside this timebox.

Ask your practice partner to introduce each changed constraint only after you have explained the first solution. If working alone, place the follow-ups in a separate note before recording, and open each one only when you reach its block.

TimeBlockOutput
0 to 5 minutesDefine Save behaviourVisible states and assumptions
5 to 15 minutesDiagnose cancellationCorrected error boundary and verification plan
15 to 27 minutesExplain Compose and restorationState ownership map
27 to 42 minutesDesign durable intentStorage and retry sequence
42 to 52 minutesHandle a lost responseReconciliation contract and failure test
52 to 60 minutesReview the attemptScores, evidence and 1 repair target

Minutes 0 to 5, decide what Save promises

Candidate prompt. A user can save an article to a personal reading list. The app should work on an unreliable connection. Describe what happens after the user taps Save.

Clarify whether the reading list is local or account-backed, whether another device can edit it, and what the UI means by “saved”. Those questions determine the system you need.

For this exercise, assume the following.

  • The reading list belongs to an account and syncs between devices.
  • The app accepts a save while offline.
  • The UI distinguishes pending sync from server-confirmed state.
  • The user may undo the save before sync completes.
  • The same article should not appear twice in 1 account's list.

Weak answer. “I'd call the API from the ViewModel, show a spinner and a snackbar on error. Room caches the list.” This promises server confirmation in a requirement that includes offline use, and it never says what the user sees when the call cannot be made.

Reasoned answer. “I will persist the user's desired saved state locally before acknowledging it. The screen can then show it as pending. Server confirmation is a separate state, and I need a policy for undo while a save is still in flight.”

The prompt already contains a product decision and a recovery problem. Starting with dependency-injection modules would skip both.

Follow-up. The product owner says “saved” should mean the server has it. What changes? The UI needs 2 visible states instead of 1, and the offline case needs an explicit message instead of a silent queue. State the cost of each choice before picking one.

Minutes 5 to 15, cancellation is not a failed save

Candidate prompt. A coroutine calls a suspending repository function inside try. Its catch (Exception) block publishes a failed-save message. What can go wrong?

Run this before you answer. It is a plain Kotlin file that needs only kotlinx-coroutines. The fake request never answers on its own, so the test controls when it ends.

import java.io.IOException
import kotlinx.coroutines.*

class FakeApi {
    val started = CompletableDeferred<Unit>()
    val outcome = CompletableDeferred<Unit>()

    suspend fun save(articleId: String) {
        started.complete(Unit)
        outcome.await()
    }
}

class SaveRepository(private val api: FakeApi) {
    var message: String? = null

    suspend fun save(articleId: String) {
        try {
            api.save(articleId)
        } catch (e: Exception) { // the line under review
            message = "Could not save"
        }
    }
}

fun main() = runBlocking {
    // 1. The owner cancels the save.
    val api1 = FakeApi()
    val repo1 = SaveRepository(api1)
    val job1 = launch { repo1.save("a1") }
    api1.started.await()
    job1.cancelAndJoin()
    println("after cancellation: ${repo1.message}")

    // 2. The network fails.
    val api2 = FakeApi()
    val repo2 = SaveRepository(api2)
    val job2 = launch { repo2.save("a1") }
    api2.started.await()
    api2.outcome.completeExceptionally(IOException("offline"))
    job2.join()
    println("after IOException: ${repo2.message}")
}

It prints “Could not save” for both runs. The first is wrong, because nobody failed. The user left, or the owner stopped the work, and the screen now carries a failure message for a save that may still be pending in the queue. Replace the catch with the 2 clauses below and run it again. The first run now prints null and the second still prints “Could not save”.

        } catch (e: CancellationException) {
            throw e
        } catch (e: IOException) {
            message = "Could not save"
        }

Weak answer. “It catches errors, so it's fine.” The answer treats cancellation as an error, and it does not say which errors the boundary owns.

Reasoned answer. A broad exception handler can consume CancellationException. Cancellation is part of coroutine control flow and should propagate rather than be converted into a normal error state. Android's coroutine guidance warns against swallowing it.[1] Rethrow cancellation first, then handle the failures this layer owns, here network failures, and let anything else surface. A catch-all message does not establish a retry policy.

Follow-up. We fixed the exception handling. The coroutine now performs a long CPU loop with no suspension. Will cancelling its job stop that loop promptly?

Cancellation is cooperative. Run this second file, then delete the ensureActive() line and run it again.

import kotlinx.coroutines.*

suspend fun checksum(rounds: Int): Long = withContext(Dispatchers.Default) {
    var sum = 0L
    for (round in 0 until rounds) {
        ensureActive() // cooperative check between rounds
        for (i in 0 until 1_000_000) sum += (i xor round).toLong()
    }
    sum
}

fun main() = runBlocking {
    val job = launch { checksum(rounds = 20_000) }
    delay(50)
    val start = System.nanoTime()
    job.cancelAndJoin()
    val ms = (System.nanoTime() - start) / 1_000_000
    println("cancelAndJoin took ${ms} ms, job cancelled: ${job.isCancelled}")
}

With the check, cancelAndJoin returns almost at once. Without it, the call waits until the loop finishes, because nothing inside the loop looks at the job. Moving the same loop to another dispatcher changes where it runs and adds no cooperation.[2]

What to verify

Use a controlled fake, as above, rather than a fast real request. Start the operation, wait until the fake reports that it began, cancel the owning job and inspect the state. Cancellation should not publish the failed-save message, and an ordinary repository failure should still follow the agreed error contract. “All errors are handled” is incomplete until it separates the 2.

If you want this cancellation check inside a scored round with a changed constraint, Android Interview Training is the structured route for it.

Minutes 15 to 27, give each state the right lifetime

Candidate prompt. The screen contains a filter, a selected article and the saved list. What survives recomposition, rotation and system-initiated process death?

Avoid placing all 3 values in the same bucket. A temporary UI choice, a reconstruction key and durable account data can require different owners.

ValueA defensible ownerReason
Open or closed filter menuLocal composable stateTemporary presentation detail
Filter text needed after restorationrememberSaveable, or SavedStateHandle in the ViewModelSmall value used to reconstruct the screen
Selected article ID needed after restorationSavedStateHandle in the screen's ViewModelRebuilds the selection without storing a full object graph
Saved article intent and sync statusPersistent local dataMust remain meaningful beyond the current process

Weak answer. “Put it all in the ViewModel, it survives rotation.” A ViewModel survives configuration changes and does not survive process death, so the filter and the selection are gone when Android recreates the process.

Reasoned answer. remember alone does not provide restoration after process death. A ViewModel survives relevant configuration changes but not process death. Saved-state mechanisms such as rememberSaveable and SavedStateHandle keep small reconstruction data across system recreation, and durable application data belongs in persistent storage.[3] Justify each owner from the lifetime the value needs, then say how the selected ID is turned back into an article after restoration, which is a read from the database.

Follow-up. The screen collects a StateFlow. Does using that type automatically stop collection when the UI is no longer active?

No. A StateFlow is a holder, and collecting from it does not stop on its own.[4] In Compose, collect it with collectAsStateWithLifecycle() from the lifecycle-runtime-compose artefact.[5] By default it collects only while the lifecycle is at least STARTED, unlike plain collectAsState(). In a View-based screen the equivalent is repeatOnLifecycle(Lifecycle.State.STARTED). Then explain whether the upstream producer keeps working with no collectors, which depends on its sharing policy. stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), initial) keeps the upstream alive for 5 seconds after the last collector leaves, so a configuration change does not restart it.[8]

Keep 1 owner for each state. Passing state down and events back to its owner is consistent with Compose's state-hoisting guidance.[5]

Minutes 27 to 42, make intent durable before scheduling work

Candidate prompt. Design the local write and the sync operation. The process can die between any 2 steps.

For the exercise, assume the server supports a desired-state operation such as “article X should be saved”, and an operation identifier that it can use to deduplicate retries. State that assumption, because an Android client cannot create a server-side guarantee by itself.

A possible sequence is as follows.

  1. Persist the desired local state and a pending operation in 1 database transaction.
  2. Let the UI observe the local data and show a pending indicator.
  3. Request persistent background work with enqueueUniqueWork.
  4. Have the worker read pending operations from storage.
  5. Send each operation with its stable identity.
  6. Record acknowledgement and update local sync status.

Weak answer. “Save to Room, then enqueue a WorkManager job.” The 2 steps are not atomic, the answer does not say what the job carries, and a second tap enqueues a second job.

Reasoned answer. Name the unique work. WorkManager.enqueueUniqueWork("sync-saves", ExistingWorkPolicy.KEEP, request) means a new request is ignored while unfinished work with that name exists. ExistingWorkPolicy.REPLACE cancels the running work and enqueues the new request in its place. For a drain worker that reads the queue from the database, KEEP is usually right, because a second tap adds a row and not a second worker, while REPLACE would stop an in-flight network call for no gain. KEEP has 1 trap. A row inserted after the running worker's last read gets no worker of its own, so the worker must re-check the queue before it returns success.[6][7]

Android's offline-first guidance discusses local data sources, queued writes and persistent work.[6] Your interview answer still needs to define the operation and what each stored state means.

Follow-up. The transaction commits, but the process dies before work is enqueued. What starts the pending operation later?

The queue exists and scheduling was missed. Add a reconciliation point, such as checking pending operations when the app next starts, and discuss whether the product needs an additional scheduled mechanism. Do not claim an exact execution time from a background-work API. The database and the scheduler have different jobs, and a database transaction does not make a separate scheduling call atomic.

Handle undo while a save is in flight

The user saves article X, then immediately removes it. If the first request completes later, its acknowledgement must not blindly restore the older desired state.

Track the local revision or operation being acknowledged. Preserve the latest local intent while reconciling older acknowledgements. Define server ordering if requests can arrive out of order. Client-side revision checks alone cannot repair an undefined server conflict policy.

You can choose a different protocol. What matters is that the answer explains the history instead of treating every response as current.

Minutes 42 to 52, recover when the response is lost

Candidate prompt. The server applied a save, but the app never received the acknowledgement. It restarts and sees the operation as pending. What happens next?

Weak answer. “It times out, so we retry with exponential backoff.” Backoff controls when to retry. It does not say what a repeated request means, and it treats a timeout as proof that nothing happened.

Reasoned answer. The outcome is uncertain from the client's side. With the assumed server contract, retry using the same operation identifier. The server must define how duplicates are recognised, how long deduplication information is kept and what response the client receives. A queryable operation status or a safe desired-state API can also reconcile it.

Follow-up. The backend does not support operation identifiers. Can we still retry safely?

It depends on the operation's semantics. Repeating “set saved to true” can be designed to be idempotent. Repeating “toggle saved” can reverse the first successful outcome. Concurrent updates still need an ordering or version policy. Name the backend requirement you need instead of hiding it behind “retry with exponential backoff”.

Write the failure test before adding more layers

Use a fake server that records a successful operation, then simulates a lost response. Recreate the client from its persisted pending state and retry.

Verify 3 things. The server holds 1 logical saved state, the pending state is eventually reconciled on the client, and a newer local undo is not rolled back. These are separate checks, and 1 happy-path assertion cannot establish all 3.

For a longer design session, continue with Android offline sync at staff level. The Kotlin coroutines questions cover language-level follow-ups in greater depth.

Minutes 52 to 60, score what you demonstrated

Score each dimension against the descriptors below. Write a timestamp or a concrete part of your answer beside each score. If you did not reach a dimension, mark it “not reached” and do not guess.

DimensionNeeds repairSenior barStrong
Product contractPromised server confirmation offline, or never defined “saved”Separated local acceptance, pending sync and confirmationAlso priced the alternative and asked which the product needs
CancellationTreated it as an error, or needed the exception pointed outRethrew it, named cooperative checks, separated it from failuresAlso wrote the fake-based test and named other swallowing patterns
State ownershipPut everything in 1 bucketMatched temporary, restorable and durable state to lifetimesAlso covered collection by lifecycle and rebuilt a selection from storage
RecoveryMissed death between persistence and schedulingAdded a reconciliation point and named unique work with KEEP or REPLACEAlso handled a worker that returns while new rows arrive
Protocol reasoningEquated timeout with failureExplained uncertain outcomes and operation identityAlso covered missing backend support and deduplication expiry
VerificationDescribed only a happy pathDefined a lost-response test with a controlled fakeAlso checked undo ordering in the same history

Count a dimension as repaired when you can explain it again, from a different operation, without the table.

Weak debrief. “I think it went fine, I just rambled a bit on WorkManager.” There is no score, no evidence and nothing to repeat.

Reasoned debrief. “Cancellation, senior bar, I rethrew it at 8 minutes. Recovery, needs repair, I missed the gap between the commit and the enqueue until the follow-up. Next session I rehearse that gap with a different operation.” That gives a score, a moment and a retry.

Choose 1 correction for the next session. For example, “I treated every timeout as a failed operation. I will rehearse reconciliation with an applied-but-unacknowledged request.”

Practise the part that exposed the gap

Android Interview Training offers a structured route through mobile interview practice. The book and companion code are yours to keep, with 90 days of Guided Practice included. It costs $99, paid once per platform. You can read the free sample before buying.

Use today's recording as a baseline. Repeat the difficult block with a different operation, such as editing a reading-list title. If the explanation only works for the memorised example, it needs another attempt.

Sources

  1. Android Developers, best practices for coroutines.
  2. Kotlin docs, coroutine cancellation.
  3. Android Developers, save UI states.
  4. Android Developers, StateFlow and SharedFlow.
  5. Android Developers, state and Jetpack Compose.
  6. Android Developers, build an offline-first app.
  7. Android Developers, manage work and unique work.
  8. Android Developers, Kotlin coroutines with lifecycle-aware components.

Questions readers ask

© 2026 Mike Salari, Interview Runtime. All rights reserved. Quoting a short excerpt with a link to this page is welcome; republishing the article, in full or in part, is not.

Practice the follow-up, not the first answer.

Interview Runtime is the interview book plus 90 days of Guided Practice: you answer first, see the one gap that would cost the point, then answer again when one fact changes.