From f881e62226cf3bd49ae9973bd5841858177eba94 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Mon, 28 Feb 2022 20:23:29 +0000 Subject: [PATCH] service: PendingIntent vs. Android M Apparently we now have to specify mutability flags. --- .../ctfwstimer/service/MainServiceNotification.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainServiceNotification.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainServiceNotification.java index 9f1ef5a..63037e9 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainServiceNotification.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainServiceNotification.java @@ -57,10 +57,15 @@ class MainServiceNotification { nm.createNotificationChannel(nc); } + int pendflags = PendingIntent.FLAG_CANCEL_CURRENT; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + pendflags |= PendingIntent.FLAG_IMMUTABLE; + } + userNoteBuilder = new NotificationCompat.Builder(ms, CTFWS_GAME_CHANNEL_ID) .setOnlyAlertOnce(false) .setSmallIcon(R.drawable.ic_hammer_and_sickle) - .setContentIntent(PendingIntent.getActivity(ms, 0, ni, 0)); + .setContentIntent(PendingIntent.getActivity(ms, 0, ni, pendflags)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { userNoteBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); -- 2.50.1