As soon as I updated the target SDK to 30 (Android R), a lint warning Missing PendingIntent mutability flag appeared on my PendingIntent.FLAG_UPDATE_CURRENT flag when I want to define PendingIntent.
Missing PendingIntent mutability flag
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent
How should I handle this lint with no effect on the app functionality?
You can set your pending intent as
val updatedPendingIntent = PendingIntent.getActivity( applicationContext, NOTIFICATION_REQUEST_CODE, updatedIntent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT // setting the mutability flag )
According to the docs here: https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability
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.
Choose your flag accordingly.
If you want to read more about this i would suggest that you read this great article here: https://medium.com/androiddevelopers/all-about-pendingintents-748c8eb8619
1.4m articles
1.4m replys
5 comments
57.0k users