Skip to content

Commit 3b5e997

Browse files
Replace PendingIntent.FLAG_UPDATE_CURRENT with PendingIntent.FLAG_CANCEL_CURRENT in InstrumentationActivityInvoker.
With FLAG_CANCEL_CURRENT, if a PendingIntent already exists with the same intent data, the previous PendingIntent is cancelled, thus removing any previous extras from the Intent. 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. In theory, this would cause a very strange bug where the new intent would start the activity but with the previous extras. PiperOrigin-RevId: 789036449
1 parent 4d65832 commit 3b5e997

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
**Bug Fixes**
88

9+
* 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.
10+
911
**New Features**
1012

1113
**Breaking Changes**

core/java/androidx/test/core/app/InstrumentationActivityInvoker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ public void startActivityForResult(Intent intent, @Nullable Bundle activityOptio
464464
getApplicationContext(),
465465
/* requestCode= */ 0,
466466
intent,
467-
/* flags= */ PendingIntent.FLAG_UPDATE_CURRENT | intentMutability))
467+
/* flags= */ PendingIntent.FLAG_CANCEL_CURRENT | intentMutability))
468468
.putExtra(TARGET_ACTIVITY_OPTIONS_BUNDLE_KEY, activityOptionsBundle);
469469

470470
getApplicationContext().startActivity(bootstrapIntent, activityOptionsBundle);

0 commit comments

Comments
 (0)