Skip to content

fix(android): set background activity launch mode for PendingIntent - #2796

Open
Luca-CZ wants to merge 1 commit into
MaikuB:masterfrom
Luca-CZ:fix/android14-pendingintent-background-activity
Open

fix(android): set background activity launch mode for PendingIntent#2796
Luca-CZ wants to merge 1 commit into
MaikuB:masterfrom
Luca-CZ:fix/android14-pendingintent-background-activity

Conversation

@Luca-CZ

@Luca-CZ Luca-CZ commented Jul 7, 2026

Copy link
Copy Markdown

see #2795

Summary

Adds explicit background activity launch handling for Android 14+ activity PendingIntents created by the plugin.

This updates PendingIntent.getActivity(...) usage to pass an ActivityOptions bundle on API 34+ and explicitly set the pending intent creator background activity start mode.

Motivation

Android 14 introduced stricter handling around background activity launches. When creating activity PendingIntents, apps should explicitly opt in or opt out of background activity start behavior instead of relying on implicit or system-defined defaults.

Previously, the plugin created activity PendingIntents for notification taps and notification actions without passing ActivityOptions.setPendingIntentCreatorBackgroundActivityStartMode(...).

This made the behavior implicit on API 34+ and could trigger Android security/compliance findings. Making the behavior explicit allows the plugin to:

  • align with Android guidance for activity pending intents
  • avoid relying on system-defined background launch behavior
  • use a secure default for notification-related activity launches

The change is backward compatible because it only applies on Android 14+ and keeps the existing behavior for older Android versions.

Implementation notes

  • Adds ActivityOptions usage to Android activity PendingIntent creation.
  • Applies to the main notification tap PendingIntent.getActivity(...) path.
  • Applies to notification action PendingIntent.getActivity(...) when showsUserInterface is true.
  • Uses Build.VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE to gate the new behavior.
  • Uses ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED as the explicit default.
  • Passes activityOptions.toBundle() to the 5-argument PendingIntent.getActivity(...) overload on API 34+.
  • Preserves the existing 4-argument PendingIntent.getActivity(...) call on older Android versions.

Testing

Tested using:

melos bootstrap
melos run analyze
melos run test:unit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant