Commit 453e7daf16d5589d4c3797f3124ca96e5c49120c
1 parent
48aa9f0e
1.Android 12 通知栏适配
Showing
2 changed files
with
7 additions
and
5 deletions
config.gradle
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/util/utilcode/util/NotificationUtils.java
| @@ -30,8 +30,9 @@ public class NotificationUtils { | @@ -30,8 +30,9 @@ public class NotificationUtils { | ||
| 30 | (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | 30 | (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); |
| 31 | 31 | ||
| 32 | // Intent para disparar o broadcast | 32 | // Intent para disparar o broadcast |
| 33 | - PendingIntent p = PendingIntent.getActivity(Utils.getApp(), 0, intent, | ||
| 34 | - Build.VERSION.SDK_INT >= 31 ? PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT); | 33 | + PendingIntent p = PendingIntent.getActivity(Utils.getApp(), 0, intent, Build.VERSION.SDK_INT >= 31 ? |
| 34 | + (PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE) : | ||
| 35 | + PendingIntent.FLAG_UPDATE_CURRENT); | ||
| 35 | 36 | ||
| 36 | // Cria a notification | 37 | // Cria a notification |
| 37 | NotificationCompat.Builder builder = new NotificationCompat.Builder(context) | 38 | NotificationCompat.Builder builder = new NotificationCompat.Builder(context) |
| @@ -51,8 +52,9 @@ public class NotificationUtils { | @@ -51,8 +52,9 @@ public class NotificationUtils { | ||
| 51 | (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | 52 | (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); |
| 52 | 53 | ||
| 53 | // Intent para disparar o broadcast | 54 | // Intent para disparar o broadcast |
| 54 | - PendingIntent p = intent != null ? PendingIntent.getActivity(Utils.getApp(), 0, intent, | ||
| 55 | - Build.VERSION.SDK_INT >= 31 ? PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT) : null; | 55 | + PendingIntent p = intent != null ? PendingIntent.getActivity(Utils.getApp(), 0, intent, Build.VERSION.SDK_INT >= 31 ? |
| 56 | + (PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE) : | ||
| 57 | + PendingIntent.FLAG_UPDATE_CURRENT) : null; | ||
| 56 | 58 | ||
| 57 | // Cria a notification | 59 | // Cria a notification |
| 58 | NotificationCompat.Builder builder = new NotificationCompat.Builder(context) | 60 | NotificationCompat.Builder builder = new NotificationCompat.Builder(context) |