Home > OS >  How to manage custom notification in android
How to manage custom notification in android

Time:11-03

warning : Field requires API level 23 (current min is 21): android.app.PendingIntent#FLAG_IMMUTABLE

`

val pendingIntent = PendingIntent.getBroadcast(
    context, NOTIFICATION_ID,
    intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)

`

how to manage this warning?

CodePudding user response:

Probably:

 val flag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE else PendingIntent.FLAG_UPDATE_CURRENT
 val pendingIntent = PendingIntent.getActivity(context, PENDING_INTENT_REQUEST_CODE, notificationIntent, flag)
  • Related