Foreground Services (FGS) Task Manager

Android 13 allows users to stop foreground services from the notification drawer, regardless of target SDK version. This new affordance, called the Foreground Services (FGS) Task Manager, shows a list of apps that are currently running a foreground service. This list is labeled Active apps. Next to each app is a Stop button. Figure 1 illustrates the FGS Task Manager workflow on a device that runs Android 13:

At the bottom of the notification drawer is a button that indicates the
  number of apps that are currently running in the background. When you press
  this button, a dialog appears that lists the names of different apps. The
  Stop button is to the right of each app
Figure 1. FGS Task Manager workflow on Android 13 devices.

User action stops your entire app

When the user presses the Stop button next to your app in the FGS Task Manager, then your entire app stops, not just the running foreground service.

Comparing behavior with "swipe up" and "force stop" user actions

Refer to the following table to see how the FGS Task Manager compares to the existing affordances: "swipe up" from the Recents screen and "force stop" a misbehaving app.

FGS Task Manager Swipe up Force stop
Immediately removes app from memory
Media playback is stopped
FGS stopped / Associated notification removed
Removes the activity back stack
Removes app from history
Scheduled jobs are canceled
Alarms are canceled

No callbacks sent when user stops app from FGS Task Manager

The system doesn't send your app any callbacks when the user presses the Stop button. When your app starts back up, it might be helpful for you to check for the new REASON_USER_REQUESTED reason that's part of the existing ApplicationExitInfo API.

System prompts related to long-running foreground services

If the system detects that your app runs a foreground service for a long period of time—at least 20 hours within a 24-hour window—the system sends a notification to the user, inviting them to interact with the FGS Task Manager.

Learn more about the new system notification that alerts users to long-running foreground service.

Exemptions

The system provides several levels of exemptions for certain types of apps, which the following sections describe.

Exemptions are per app, not per process. If the system exempts one process in an app, all other processes in that app are also exempt.

Exemptions from appearing in the FGS Task Manager at all

The following apps can run a foreground service and not appear in the task manager at all:

Exemptions from being stoppable by users

When the following types of apps run a foreground service, they appear in the FGS Task Manager, but there is no Stop button next to the app's name for the user to press:

Testing

To test that your app is behaving as expected while and after a user stops your app, run the following ADB command in a terminal window:

adb shell cmd activity stop-app PACKAGE_NAME