BackgroundActivityStartMode Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Specifies policy modes for background activity starts through pending intents.
public enum BackgroundActivityStartMode
type BackgroundActivityStartMode =
- Inheritance
-
BackgroundActivityStartMode
Fields
| Name | Value | Description |
|---|---|---|
| SystemDefined | 0 | The system determines whether to grant background activity start privileges. This is the default behavior if no explicit mode is specified. Android reference for Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. |
| Allowed | 1 | Grants the PendingIntent background activity start privileges. This behaves the same as AllowAlways, except it does not grant background activity launch permissions based on the privileged permission START_ACTIVITIES_FROM_BACKGROUND. This constant was deprecated in API level 36. Use AllowIfVisible to allow starts only when the app is visible or AllowAlways to allow starts at any time (see Restrictions on starting activities from the background). Android reference for Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. |
| Denied | 2 | Denies the PendingIntent any background activity start privileges. Android reference for Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. |
| AllowAlways | 3 | Grants the PendingIntent all background activity start privileges, including those normally reserved for privileged contexts (e.g., companion apps or those with the START_ACTIVITIES_FROM_BACKGROUND permission). Caution: This mode should be used sparingly. Most apps should use AllowIfVisible instead, relying on notifications or foreground services for background interactions to minimize user disruption. However, this mode is necessary for specific use cases, such as companion apps responding to prompts from a connected device. For more information, see Restrictions on starting activities from the background. Android reference for Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. |
| AllowIfVisible | 4 | Grants the PendingIntent background activity start privileges only when the app has a visible window (i.e., is visible to the user). This is the recommended mode for most apps to minimize disruption to the user experience. For more information, see Restrictions on starting activities from the background. Android reference for Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. |
Remarks
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.