File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
app/src/main/java/it/niedermann/owncloud/notes/shared/util Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -16,18 +16,21 @@ private WidgetUtil() {
1616 }
1717
1818 /**
19- * Android S requires either {@link PendingIntent#FLAG_MUTABLE} or
20- * {@link PendingIntent#FLAG_IMMUTABLE} to be set on a {@link PendingIntent}.
21- * This is enforced by Android and will lead to an app crash if neither of those flags is
22- * present.
23- * To keep the app working, this compatibility method can be used to add the
24- * {@link PendingIntent#FLAG_MUTABLE} flag on Android S and higher to restore the behavior of
25- * older SDK versions.
19+ * Android 14 (API 34) and above require FLAG_IMMUTABLE
2620 *
27- * @param flags wanted flags for {@link PendingIntent}
28- * @return {@param flags} | {@link PendingIntent#FLAG_MUTABLE}
21+ * <p>
22+ * Android 12 (API 31) and above allow FLAG_MUTABLE
23+ *
24+ * <p>
25+ * Ensures compatibility with different Android API levels by setting appropriate flags for a PendingIntent.
26+ *
27+ * @param flags The original flags to be used for the PendingIntent.
28+ * @return The modified flags with compatibility adjustments based on the Android API level.
2929 */
3030 public static int pendingIntentFlagCompat (int flags ) {
31+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .UPSIDE_DOWN_CAKE ) {
32+ return flags | PendingIntent .FLAG_IMMUTABLE ;
33+ }
3134 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .S ) {
3235 return flags | PendingIntent .FLAG_MUTABLE ;
3336 }
You can’t perform that action at this time.
0 commit comments