]> hydra-www.ietfng.org Git - acmetensortoys-ctfws-android/commitdiff
service: PendingIntent vs. Android M
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Mon, 28 Feb 2022 20:23:29 +0000 (20:23 +0000)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Wed, 2 Mar 2022 23:39:37 +0000 (23:39 +0000)
Apparently we now have to specify mutability flags.

mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainServiceNotification.java

index 9f1ef5a4457540084f265035cd2ccddb84047268..63037e93d574fe555648bcdb06cb2182b308ab97 100644 (file)
@@ -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);