Open jinlongwu opened 1 year ago
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
//android 12 必须使用 PendingIntent.FLAG_MUTABLE 模式
val pendingIntent = PendingIntent.getActivity(
context, REQUEST_CODE, intent, PendingIntent.FLAG_MUTABLE
)
builder.setContentIntent(pendingIntent)
} else {
val pendingIntent = PendingIntent.getActivity(
context,
REQUEST_CODE, intent,
PendingIntent.FLAG_ONE_SHOT
);
builder.setContentIntent(pendingIntent)
}
PACKAGE_NAME: Targeting S+ (version 10000 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.