From 68d22379d690499fa274597f66639ad9ceeebc6f Mon Sep 17 00:00:00 2001 From: AndroidX Test Team Date: Wed, 30 Jul 2025 14:08:28 -0700 Subject: [PATCH] Replace PendingIntent.FLAG_UPDATE_CURRENT with PendingIntent.FLAG_CANCEL_CURRENT in InstrumentationActivityInvoker. FLAG_CANCEL_CURRENT solves the issue where the system caches the extras from the previous intent for the PendingIntent and thus the extras passed to the PendingIntent for the new Intent would be ignored when the action between previous intent and new intent are same. PiperOrigin-RevId: 789036449 --- core/CHANGELOG.md | 2 ++ .../androidx/test/core/app/InstrumentationActivityInvoker.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index e5c230db6..c83d62dd6 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -6,6 +6,8 @@ **Bug Fixes** +* Fixes the issue where the system caches the extras from the previous intent for the PendingIntent and thus the extras passed to the PendingIntent for the new Intent would be ignored. + **New Features** **Breaking Changes** diff --git a/core/java/androidx/test/core/app/InstrumentationActivityInvoker.java b/core/java/androidx/test/core/app/InstrumentationActivityInvoker.java index dbaa81c6c..eb9af53f8 100644 --- a/core/java/androidx/test/core/app/InstrumentationActivityInvoker.java +++ b/core/java/androidx/test/core/app/InstrumentationActivityInvoker.java @@ -464,7 +464,7 @@ public void startActivityForResult(Intent intent, @Nullable Bundle activityOptio getApplicationContext(), /* requestCode= */ 0, intent, - /* flags= */ PendingIntent.FLAG_UPDATE_CURRENT | intentMutability)) + /* flags= */ PendingIntent.FLAG_CANCEL_CURRENT | intentMutability)) .putExtra(TARGET_ACTIVITY_OPTIONS_BUNDLE_KEY, activityOptionsBundle); getApplicationContext().startActivity(bootstrapIntent, activityOptionsBundle);