修复:转发短信出错(Targeting S+(version 31 and above) requires that one of FLAG_IMMUATABLE)

This commit is contained in:
pppscn 2022-02-14 10:19:16 +08:00
parent a7fdf68ef1
commit 89cd86326a
1 changed files with 6 additions and 2 deletions

View File

@ -37,8 +37,12 @@ public class SmsUtil {
for (String mobile : mobileArray) {
try {
SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId);
@SuppressLint("UnspecifiedImmutableFlag") PendingIntent sendPI = PendingIntent.getBroadcast(context, 0, new Intent(Context.TELEPHONY_SUBSCRIPTION_SERVICE), PendingIntent.FLAG_ONE_SHOT);
@SuppressLint("UnspecifiedImmutableFlag") PendingIntent deliverPI = PendingIntent.getBroadcast(context, 0, new Intent("DELIVERED_SMS_ACTION"), 0);
int sendFlags = Build.VERSION.SDK_INT >= 30 ? PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_ONE_SHOT;
PendingIntent sendPI = PendingIntent.getBroadcast(context, 0, new Intent(Context.TELEPHONY_SUBSCRIPTION_SERVICE), sendFlags);
int deliverFlags = Build.VERSION.SDK_INT >= 30 ? PendingIntent.FLAG_IMMUTABLE : 0;
PendingIntent deliverPI = PendingIntent.getBroadcast(context, 0, new Intent("DELIVERED_SMS_ACTION"), deliverFlags);
ArrayList<PendingIntent> sentPendingIntents = new ArrayList<>();
ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<>();