Handle user-initiated stopping of apps running foreground services
bookmark_borderbookmark
Stay organized with collections
Save and categorize content based on your preferences.
Starting in Android 13 (API level 33), users can complete a workflow from the
notification drawer
to stop an app that has an ongoing foreground services, regardless of that app's
target SDK version. This affordance, called the
Task Manager, shows a list of apps that are
currently running a foreground service.
Figure 1. Task Manager workflow on devices that
run Android 13 or higher.
This list is labeled Active apps.
Next to each app is a Stop button. Figure 1 illustrates the
Task Manager workflow on a device that runs
Android 13.
When the user presses the Stop button next to your app in the
Task Manager, then the following actions occur:
The system removes your app from memory. Therefore, your entire app stops,
not just the running foreground service.
The system removes your app's activity back stack.
Any media playback stops.
The notification associated with the foreground service is removed.
Your app remains in history.
Scheduled jobs execute at their scheduled time.
Alarms go off at their scheduled time or time window.
To test that your app behaves as expected while and after a user stops your
app, run the following ADB command in a terminal window:
Android allows your app to do work in the background. Here's how.
Updated Feb 21, 2025
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-21 UTC."],[],[]]
Please help us improve the Android Developer experience by taking a short survey.