Mohammad Hanif Shaikh
Mohammad Hanif Shaikh

Reputation: 1481

How to manage custom notification in android

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?

Upvotes: 0

Views: 91

Answers (1)

Top4o
Top4o

Reputation: 674

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)

Upvotes: 1

Related Questions