App crashes at runtime with the following error :
Targeting S+ (version 31 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.
I tried all solutions available but the app still crashing on Android 12.
private Notification buildNotification() {
int playButtonResId = isPaused ? R.drawable.ic_play_arrow_white_24dp : R.drawable.ic_pause_white_24dp;
PendingIntent clickIntent = PendingIntent.getActivity(
this, 1,
new Intent(this, MainActivity.class),
PendingIntent.FLAG_IMMUTABLE);