Commit 453e7daf16d5589d4c3797f3124ca96e5c49120c

Authored by 朱显松
1 parent 48aa9f0e

1.Android 12 通知栏适配

config.gradle
... ... @@ -21,7 +21,7 @@ ext {
21 21 //编译方式
22 22 debug : false,
23 23 //版本号
24   - version: "0.4.9",
  24 + version: "0.5.0",
25 25 //Lib库前缀
26 26 packeg : "com.cnlive.module",
27 27 //Lib库名称
... ...
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/util/utilcode/util/NotificationUtils.java
... ... @@ -30,8 +30,9 @@ public class NotificationUtils {
30 30 (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
31 31  
32 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 37 // Cria a notification
37 38 NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
... ... @@ -51,8 +52,9 @@ public class NotificationUtils {
51 52 (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
52 53  
53 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 59 // Cria a notification
58 60 NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
... ...