1

I want to custom notification like image. In android 12, my custom notification not is not fit the notification area width. How can I fix it? Here is my notification:

    val builder = NotificationCompat.Builder(this, channelId)
        .setSmallIcon(R.drawable.img_app_logo)
        .setCustomContentView(remoteViews)
        .setCustomBigContentView(remoteViews)
        .setCustomHeadsUpContentView(remoteViews)
        .setPriority(NotificationCompat.PRIORITY_HIGH)
        .setAutoCancel(true)
        .addAction(optimizeAction)
    cancelAction?.let {
        builder.addAction(it)
    }
    notificationManager.notify(notificationId, builder.build())

Thanks

Vishal Vasani
  • 647
  • 8
  • 16

1 Answers1

-1

You should change the targetSdkVersion from the build.gradle file to something below 31. (30 worked for me)

More information here: https://developer.android.com/about/versions/12/behavior-changes-12