android 12 FLAG_IMMUTABLE

This commit is contained in:
csf 2022-04-19 23:37:30 +08:00
parent 59e7d53e7d
commit c66cf22c46

View File

@ -560,7 +560,11 @@ class MainService : Service() {
addCategory(Intent.CATEGORY_LAUNCHER)
putExtra("type", type)
}
val pendingIntent = PendingIntent.getActivity(this, 0, intent, FLAG_UPDATE_CURRENT)
val pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PendingIntent.getActivity(this, 0, intent, FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE)
} else {
PendingIntent.getActivity(this, 0, intent, FLAG_UPDATE_CURRENT)
}
val notification = notificationBuilder
.setOngoing(true)
.setSmallIcon(R.mipmap.ic_launcher)