Commit 6c4769729e8bb411d7b8a8037624db7472ccd6e4
1 parent
482524a1
1.Android 12 通知栏适配
Showing
3 changed files
with
9 additions
and
4 deletions
config.gradle
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/util/subutil/util/DangerousUtils.java
| ... | ... | @@ -317,7 +317,8 @@ public class DangerousUtils { |
| 317 | 317 | @RequiresPermission(SEND_SMS) |
| 318 | 318 | public static void sendSmsSilent(final String phoneNumber, final String content) { |
| 319 | 319 | if (TextUtils.isEmpty(content)) return; |
| 320 | - PendingIntent sentIntent = PendingIntent.getBroadcast(Utils.getApp(), 0, new Intent("send"), 0); | |
| 320 | + PendingIntent sentIntent = PendingIntent.getBroadcast(Utils.getApp(), 0, new Intent("send"), | |
| 321 | + Build.VERSION.SDK_INT >= 31 ? PendingIntent.FLAG_IMMUTABLE : 0); | |
| 321 | 322 | SmsManager smsManager = SmsManager.getDefault(); |
| 322 | 323 | if (content.length() >= 70) { |
| 323 | 324 | List<String> ms = smsManager.divideMessage(content); | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/util/utilcode/util/NotificationUtils.java
| ... | ... | @@ -5,6 +5,8 @@ import android.app.NotificationManager; |
| 5 | 5 | import android.app.PendingIntent; |
| 6 | 6 | import android.content.Context; |
| 7 | 7 | import android.content.Intent; |
| 8 | +import android.os.Build; | |
| 9 | + | |
| 8 | 10 | import androidx.annotation.Nullable; |
| 9 | 11 | import androidx.core.app.NotificationCompat; |
| 10 | 12 | import androidx.core.app.NotificationManagerCompat; |
| ... | ... | @@ -28,7 +30,8 @@ public class NotificationUtils { |
| 28 | 30 | (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); |
| 29 | 31 | |
| 30 | 32 | // Intent para disparar o broadcast |
| 31 | - PendingIntent p = PendingIntent.getActivity(Utils.getApp(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); | |
| 33 | + PendingIntent p = PendingIntent.getActivity(Utils.getApp(), 0, intent, | |
| 34 | + Build.VERSION.SDK_INT >= 31 ? PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT); | |
| 32 | 35 | |
| 33 | 36 | // Cria a notification |
| 34 | 37 | NotificationCompat.Builder builder = new NotificationCompat.Builder(context) |
| ... | ... | @@ -48,7 +51,8 @@ public class NotificationUtils { |
| 48 | 51 | (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); |
| 49 | 52 | |
| 50 | 53 | // Intent para disparar o broadcast |
| 51 | - PendingIntent p = intent != null ? PendingIntent.getActivity(Utils.getApp(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) : null; | |
| 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; | |
| 52 | 56 | |
| 53 | 57 | // Cria a notification |
| 54 | 58 | NotificationCompat.Builder builder = new NotificationCompat.Builder(context) | ... | ... |