From: Nathaniel Wesley Filardo Date: Mon, 28 Feb 2022 20:23:29 +0000 (+0000) Subject: service: PendingIntent vs. Android M X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=f881e62226cf3bd49ae9973bd5841858177eba94;p=acmetensortoys-ctfws-android service: PendingIntent vs. Android M Apparently we now have to specify mutability flags. --- 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);