How to test Android process death with ADB
To test Android process death, open an unfinished task in your test app, press Home and run
adb shell am kill with the app’s package name. Confirm that the process ID disappears, then
tap the app’s card in Recents. Check which screen opens and whether the work you entered
is still there. Android’s ADB command reference.
How do you confirm the Android process actually ended?
Connect one test device or start one emulator and check that adb devices lists it as device.
If you have several connected, add -s SERIAL after adb in each command. Get the installed
test build’s application ID from engineering. It may have a suffix such as .debug.
Android’s ADB device setup.
-
Open a screen with something to restore. For example, add a title and a sample photo to an inspection draft. Note the step you’re on and use a recognisable title like
Pump check A. -
With the app open, run
adb shell pidof com.example.app, replacingcom.example.appwith your test build’s ID. Note the number it prints. If it prints nothing while the screen is open, check the ID. If the screen runs in a separately named process, ask engineering for that process name and use it for thepidofchecks. -
Go Home and leave the app’s card in Recents. Run these lines in the same terminal. Set
app_idto your test build’s ID and use the same process name forpidofas in step 2.app_id=com.example.app adb shell am kill \ --user current "$app_id" adb shell pidof "$app_id" -
When
pidofshows no ID, open Recents and tap the existing app card. Runpidofagain to record the new process ID, then check the screen and draft.
If the old ID is still there, Android hasn’t ended that process. Give the app a moment in the
background and try again. If a foreground service is keeping it active, try a flow without that
service or ask engineering how to test that particular flow. Record the run as inconclusive if
you can’t verify the exit. Android limits am kill to processes it can safely end. Keep
Don’t keep activities off for this run so going Home doesn’t also trigger the developer
option that destroys the activity.
Android’s activity manager command reference.
Android’s developer options guide.
What should come back when you reopen the task?
Agree with the team what the screen should restore. In the inspection example, the title and sample photo should still belong to draft A. Tap the photo to check it opens. If the app takes you back to the draft list, check whether you can reopen A there. That tells engineering whether the app lost the draft or lost your place in it.
Run the same steps once without ending the process. If the draft also disappears when you return straight from Home, start with the interruption testing checklist. If the failure only appears after the verified exit, report the two results together. Android’s state guide distinguishes short-lived screen state, such as a search query, from data that should survive in persistent storage. Android’s guide to saving UI state.
For a draft that was already submitting, check the test record before tapping Submit again. If the app offers a retry, verify that using it leaves one inspection saved.
What goes in an Android process-death bug report?
Include the build, device and Android version, what was on screen, how you ended the process and how you returned. Here’s an example you could copy into the bug report template generator.
- Title — Inspection draft loses its photo after background process death.
- Setup — Build 412, Android 16 emulator. Draft
Pump check Awith one sample photo. - Steps — Leave the editor open, go Home, run
am kill --user currentfor the test package, then tap the existing Recents card. - Process check — PID 8124 before Home, no PID after the command, PID 8361 after reopening.
- Expected — The title and sample photo are still on draft A.
- Actual — The title returns and the photo slot is empty. Reopening the draft from the list still shows an empty slot. Reproduced twice. The photo stayed attached in the Home-only run.
Frequently asked questions
Can I use Don’t keep activities to test process death?
Don’t keep activities destroys activities when you leave them. The app process can stay alive, so use a separate run where you verify that the process itself exited.
Why does adb shell am kill leave my app running?
Android only kills processes it considers safe to end. Open the Home screen first and check the process ID again after the command. If it is still running, the test has not exercised restoration after process death.
Should I force-stop the app or swipe it away from Recents?
Keep those as separate tests. For background process death, leave the task in Recents, end its background process with adb shell am kill and reopen that same task.